Skip to content

Commit

Permalink
Merge pull request #127 from vektah/gqlerr-unwrap
Browse files Browse the repository at this point in the history
Allow unwraping of wrapping gqlerrors
  • Loading branch information
lwc authored Sep 9, 2020
2 parents d7ac1ee + 149cf70 commit 83ee611
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 83ee611

Please sign in to comment.