Skip to content

Commit

Permalink
Add response body to log
Browse files Browse the repository at this point in the history
  • Loading branch information
trapacska authored Feb 13, 2024
1 parent 494b3cc commit c52429d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion filedownloader/filedownloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ func download(context context.Context, client HTTPClient, source string, destina
}()

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("unable to download file from: %s. Status code: %d", source, resp.StatusCode)
responseBodyBytes, _ := io.ReadAll(resp.Body)
return fmt.Errorf("unable to download file from: %s. Status code: %d. Response body: %s", source, resp.StatusCode, string(responseBodyBytes))
}

if _, err = io.Copy(destination, resp.Body); err != nil {
Expand Down

0 comments on commit c52429d

Please sign in to comment.