Skip to content

Commit

Permalink
Added holder for originalError in FormattedError
Browse files Browse the repository at this point in the history
  • Loading branch information
racerxdl committed Sep 8, 2018
1 parent 5c1be08 commit 0e7ef16
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions gqlerrors/formatted.go
Expand Up @@ -12,10 +12,15 @@ type ExtendedError interface {
}

type FormattedError struct {
Message string `json:"message"`
Locations []location.SourceLocation `json:"locations"`
Path []interface{} `json:"path,omitempty"`
Extensions map[string]interface{} `json:"extensions,omitempty"`
Message string `json:"message"`
Locations []location.SourceLocation `json:"locations"`
Path []interface{} `json:"path,omitempty"`
Extensions map[string]interface{} `json:"extensions,omitempty"`
originalError error
}

func (g FormattedError) OriginalError() error {
return g.originalError
}

func (g FormattedError) Error() string {
Expand All @@ -33,9 +38,10 @@ func FormatError(err error) FormattedError {
return err
case *Error:
ret := FormattedError{
Message: err.Error(),
Locations: err.Locations,
Path: err.Path,
Message: err.Error(),
Locations: err.Locations,
Path: err.Path,
originalError: err,
}
if err := err.OriginalError; err != nil {
if extended, ok := err.(ExtendedError); ok {
Expand Down

0 comments on commit 0e7ef16

Please sign in to comment.