Skip to content

Commit

Permalink
Gracefully handle JSON decode error on erroneous API response (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
bassettb authored Feb 28, 2023
1 parent c6f2e5b commit b461ef9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion error.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func parseErrorResponse(res *http.Response) error {

err := json.NewDecoder(res.Body).Decode(&apiErr)
if err != nil {
return fmt.Errorf("failed to parse error from HTTP response: %w", err)
return &APIError{Status: res.StatusCode}
}

return &apiErr
Expand Down

0 comments on commit b461ef9

Please sign in to comment.