Skip to content

Commit 8c25a9a

Browse files
racerxdlchris-ramon
authored andcommitted
Added holder for originalError in FormattedError
1 parent 8000299 commit 8c25a9a

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

gqlerrors/formatted.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ type ExtendedError interface {
1212
}
1313

1414
type FormattedError struct {
15-
Message string `json:"message"`
16-
Locations []location.SourceLocation `json:"locations"`
17-
Path []interface{} `json:"path,omitempty"`
18-
Extensions map[string]interface{} `json:"extensions,omitempty"`
15+
Message string `json:"message"`
16+
Locations []location.SourceLocation `json:"locations"`
17+
Path []interface{} `json:"path,omitempty"`
18+
Extensions map[string]interface{} `json:"extensions,omitempty"`
19+
originalError error
20+
}
21+
22+
func (g FormattedError) OriginalError() error {
23+
return g.originalError
1924
}
2025

2126
func (g FormattedError) Error() string {
@@ -33,9 +38,10 @@ func FormatError(err error) FormattedError {
3338
return err
3439
case *Error:
3540
ret := FormattedError{
36-
Message: err.Error(),
37-
Locations: err.Locations,
38-
Path: err.Path,
41+
Message: err.Error(),
42+
Locations: err.Locations,
43+
Path: err.Path,
44+
originalError: err,
3945
}
4046
if err := err.OriginalError; err != nil {
4147
if extended, ok := err.(ExtendedError); ok {

0 commit comments

Comments
 (0)