Skip to content

Commit

Permalink
Allow unwraping of wrapping gqlerrors
Browse files Browse the repository at this point in the history
  • Loading branch information
lwc committed Aug 27, 2020
1 parent d7ac1ee commit 149cf70
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gqlerror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

// Error is the standard graphql error type described in https://facebook.github.io/graphql/draft/#sec-Errors
type Error struct {
err error `json:"-"`
Message string `json:"message"`
Path ast.Path `json:"path,omitempty"`
Locations []Location `json:"locations,omitempty"`
Expand Down Expand Up @@ -66,6 +67,10 @@ func (err Error) pathString() string {
return err.Path.String()
}

func (err Error) Unwrap() error {
return err.err
}

func (errs List) Error() string {
var buf bytes.Buffer
for _, err := range errs {
Expand All @@ -77,6 +82,7 @@ func (errs List) Error() string {

func WrapPath(path ast.Path, err error) *Error {
return &Error{
err: err,
Message: err.Error(),
Path: path,
}
Expand Down

0 comments on commit 149cf70

Please sign in to comment.