chore: improve logging
This commit is contained in:
parent
f3ec9005f7
commit
c4c1a15b00
2 changed files with 8 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue