Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More easier to extend error #550

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ func completeValue(eCtx *executionContext, returnType Type, fieldASTs []*ast.Fie
FieldASTsToNodeASTs(fieldASTs),
path.AsArray(),
)
panic(gqlerrors.FormatError(err))
panic(err)
}
return completed
}
Expand Down Expand Up @@ -746,7 +746,7 @@ func completeValue(eCtx *executionContext, returnType Type, fieldASTs []*ast.Fie
`Cannot complete value of unexpected type "%v."`, returnType)

if err != nil {
panic(gqlerrors.FormatError(err))
panic(err)
}
return nil
}
Expand All @@ -763,11 +763,11 @@ func completeThunkValueCatchingError(eCtx *executionContext, returnType Type, fi
propertyFn, ok := result.(func() (interface{}, error))
if !ok {
err := gqlerrors.NewFormattedError("Error resolving func. Expected `func() (interface{}, error)` signature")
panic(gqlerrors.FormatError(err))
panic(err)
}
fnResult, err := propertyFn()
if err != nil {
panic(gqlerrors.FormatError(err))
panic(err)
}

result = fnResult
Expand Down Expand Up @@ -892,7 +892,7 @@ func completeListValue(eCtx *executionContext, returnType *List, fieldASTs []*as
"for field %v.%v.", parentTypeName, info.FieldName)

if err != nil {
panic(gqlerrors.FormatError(err))
panic(err)
}

itemType := returnType.OfType
Expand Down
7 changes: 6 additions & 1 deletion gqlerrors/formatted.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ func FormatError(err error) FormattedError {
case Error:
return FormatError(&err)
default:
return FormattedError{
ret := FormattedError{
Message: err.Error(),
Locations: []location.SourceLocation{},
originalError: err,
}

if extended, ok := err.(ExtendedError); ok {
ret.Extensions = extended.Extensions()
}
return ret
}
}

Expand Down