Skip to content

Commit

Permalink
chore(tm2/pkg/std): add failing regexp in MemPackage.Validate's errors (
Browse files Browse the repository at this point in the history
#1673)

This helps a cli user to know what went wrong directly (otherwise, he
has to look at gno/tm2/pkg/std/memfile.go).
Since the cli user is a technical one, it makes no sense to not show
this.

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

Co-authored-by: grepsuzette <grepsuzette@users.noreply.github.com>
  • Loading branch information
grepsuzette and grepsuzette authored Feb 21, 2024
1 parent 22fa02a commit 9c898cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tm2/pkg/std/memfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ var (
// NOTE: this is to prevent conflicts with nested paths.
func (mempkg *MemPackage) Validate() error {
if !rePkgName.MatchString(mempkg.Name) {
return errors.New(fmt.Sprintf("invalid package name %q", mempkg.Name))
return errors.New(fmt.Sprintf("invalid package name %q, failed to match %q", mempkg.Name, rePkgName))
}
if !rePkgOrRlmPath.MatchString(mempkg.Path) {
return errors.New(fmt.Sprintf("invalid package/realm path %q", mempkg.Path))
return errors.New(fmt.Sprintf("invalid package/realm path %q, failed to match %q", mempkg.Path, rePkgOrRlmPath))
}
fnames := map[string]struct{}{}
for _, memfile := range mempkg.Files {
if !reFileName.MatchString(memfile.Name) {
return errors.New(fmt.Sprintf("invalid file name %q", memfile.Name))
return errors.New(fmt.Sprintf("invalid file name %q, failed to match %q", memfile.Name, reFileName))
}
if _, exists := fnames[memfile.Name]; exists {
return errors.New(fmt.Sprintf("duplicate file name %q", memfile.Name))
Expand Down

0 comments on commit 9c898cd

Please sign in to comment.