-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3e516b
commit 9fd2d62
Showing
3 changed files
with
65 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
package graphql | ||
|
||
import "fmt" | ||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
// HTTPError represents an HTTP error with status code and response body. | ||
// HTTPError represents an HTTP error with status coqgqde and response body. | ||
type HTTPError struct { | ||
Body string | ||
Response Response | ||
StatusCode int | ||
} | ||
|
||
// Error implements the error interface for HTTPError. | ||
func (e *HTTPError) Error() string { | ||
return fmt.Sprintf("returned error %v: '%s'", e.StatusCode, e.Body) | ||
jsonBody, err := json.Marshal(e.Response) | ||
if err != nil { | ||
return fmt.Sprintf("returned error %v: '%s'", e.StatusCode, e.Response) | ||
} | ||
|
||
return fmt.Sprintf("returned error %v: %s", e.StatusCode, jsonBody) | ||
} |