chore: improve logging

This commit is contained in:
Oleh Astappiev 2024-12-08 21:19:14 +01:00
parent f3ec9005f7
commit c4c1a15b00
No known key found for this signature in database
GPG key ID: 37D7AC22589E9632
2 changed files with 8 additions and 3 deletions

View file

@ -50,7 +50,12 @@ func sendRequest(ctx context.Context, url string, body interface{}, headers http
defer func() {
_ = resp.Body.Close()
}()
return nil, fmt.Errorf("request failed with status %d", status)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("request failed with status %d (failed to read body: %v)", status, err)
}
return nil, fmt.Errorf("request failed with status %d (%v)", status, string(respBody))
}
return resp, nil