Handling for non-json response (#881)

* removed handling for non-json response

* added response body in RequestError.Error() and updated tests

* done linting
This commit is contained in:
Ayush Sawant
2024-10-22 02:19:34 +05:30
committed by GitHub
parent 9fe2c6ce1f
commit fb15ff9dcd
3 changed files with 24 additions and 19 deletions

View File

@@ -289,9 +289,6 @@ func (c *Client) handleErrorResp(resp *http.Response) error {
if err != nil {
return fmt.Errorf("error, reading response body: %w", err)
}
if !strings.HasPrefix(resp.Header.Get("Content-Type"), "application/json") {
return fmt.Errorf("error, status code: %d, status: %s, body: %s", resp.StatusCode, resp.Status, body)
}
var errRes ErrorResponse
err = json.Unmarshal(body, &errRes)
if err != nil || errRes.Error == nil {