Skip to content

Commit

Permalink
Fix multiple errors wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Petya authored and tatiNo5 committed Oct 6, 2022
1 parent e0a6366 commit 9ab0a68
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,13 @@ func validate(data, schema interface{}) error {

func processResult(result *gojsonschema.Result) error {
if !result.Valid() {
var err error
err := errInvalidPerSchema

for _, rerr := range result.Errors() {
ctx := convertJSONContext(rerr.Context().String())
ctxErr := &errWithContext{msg: rerr.Description(), context: ctx}

err = fmt.Errorf("%w: %v", errInvalidPerSchema, ctxErr)

err = fmt.Errorf("%w: %v", err, ctxErr)
ferr := formatErrs.get(rerr.Details()["format"], rerr.Value())
if ferr != nil {
err = fmt.Errorf("%w: %v", err, ferr.Error())
Expand Down

0 comments on commit 9ab0a68

Please sign in to comment.