Skip to content

Commit bceab16

Browse files
committed
Improve error handling for predefined constraints
1 parent 74f0326 commit bceab16

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

internal/constraints/cache.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
package constraints
1616

1717
import (
18-
"fmt"
19-
2018
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
2119
"github.com/bufbuild/protovalidate-go/celext"
2220
"github.com/bufbuild/protovalidate-go/internal/errors"
@@ -62,10 +60,10 @@ func (c *Cache) Build(
6260
}
6361

6462
if err = reparseUnrecognized(extensionTypeResolver, constraints); err != nil {
65-
return nil, fmt.Errorf("error reparsing message: %w", err)
63+
return nil, errors.NewCompilationErrorf("error reparsing message: %w", err)
6664
}
6765
if !allowUnknownFields && len(constraints.GetUnknown()) > 0 {
68-
return nil, errors.NewCompilationErrorf("unknown rules in %s", constraints.Descriptor().FullName())
66+
return nil, errors.NewCompilationErrorf("unknown constraints in %s", constraints.Descriptor().FullName())
6967
}
7068

7169
env, err = c.prepareEnvironment(env, fieldDesc, constraints, forItems)

0 commit comments

Comments
 (0)