1
0
mirror of https://github.com/dstotijn/go-notion.git synced 2025-06-06 23:36:14 +02:00

Gracefully handle JSON decode error on erroneous API response (#51)

This commit is contained in:
bassettb 2023-02-28 13:08:08 -05:00 committed by GitHub
parent c6f2e5b343
commit b461ef999d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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