Skip to content

Commit

Permalink
Use 'errors.Join'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Apr 3, 2024
1 parent a2fa0b6 commit 7423dc9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ module github.com/hashicorp/aws-cloudformation-resource-schema-sdk-go

go 1.21

require (
github.com/hashicorp/go-multierror v1.1.1
github.com/xeipuuv/gojsonschema v1.2.0
)
require github.com/xeipuuv/gojsonschema v1.2.0

require (
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
)
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
10 changes: 5 additions & 5 deletions json_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
package cfschema

import (
"errors"
"fmt"
"os"
"path/filepath"

"github.com/hashicorp/go-multierror"
"github.com/xeipuuv/gojsonschema"
)

Expand Down Expand Up @@ -44,17 +44,17 @@ func (s *jsonSchema) validate(loader gojsonschema.JSONLoader) error {
result, err := s.schema.Validate(loader)

if err != nil {
return fmt.Errorf("Unable to Validate JSON Schema: %w", err)
return fmt.Errorf("validating JSON Schema: %w", err)
}

if !result.Valid() {
var errs *multierror.Error
var errs []error

for _, resultError := range result.Errors() {
errs = multierror.Append(errs, fmt.Errorf("%s", resultError.String()))
errs = append(errs, errors.New(resultError.String()))
}

return fmt.Errorf("Validation Errors: %w", errs)
return fmt.Errorf("validation errors: %w", errors.Join(errs...))

Check failure on line 57 in json_schema.go

View workflow job for this annotation

GitHub Actions / go test

undefined: errors.Join

Check failure on line 57 in json_schema.go

View workflow job for this annotation

GitHub Actions / go test

undefined: errors.Join
}

return nil
Expand Down

0 comments on commit 7423dc9

Please sign in to comment.