Skip to content

Commit

Permalink
feat(client): include response body in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
NateScarlet committed Aug 25, 2022
1 parent efcba4c commit 05ee580
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/client/get_html.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ func GetHTML(ctx context.Context, url string, options ...GetHTMLOption) (res Get
func makeGetHTMLResult(ctx context.Context, resp *http.Response) (res GetHTMLResult, err error) {
err = func() (err error) {
defer resp.Body.Close()
if resp.StatusCode >= 400 {
err = fmt.Errorf("response status %d", resp.StatusCode)
return
}
res.response = resp
res.body, err = io.ReadAll(resp.Body)
if err != nil {
return
}
if resp.StatusCode >= 400 {
err = fmt.Errorf("response status %d\n\n%s", resp.StatusCode, res.body)
return
}
return
}()
if err != nil {
Expand Down

0 comments on commit 05ee580

Please sign in to comment.