Skip to content

Commit

Permalink
gqlerror: implement List.Unwrap (#290)
Browse files Browse the repository at this point in the history
Go 1.20 has added a new Unwrap method for error values
holding multiple errors. Implement this method as that
errors.Is/As work as expected.
  • Loading branch information
emersion authored Jan 10, 2024
1 parent a942954 commit 591c98b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gqlerror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ func (errs List) As(target interface{}) bool {
return false
}

func (errs List) Unwrap() []error {
l := make([]error, len(errs))
for i, err := range errs {
l[i] = err
}
return l
}

func WrapPath(path ast.Path, err error) *Error {
if err == nil {
return nil
Expand Down

0 comments on commit 591c98b

Please sign in to comment.