summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-26 15:35:53 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-09-26 15:35:53 +0200
commita117903084110922c5e242fa6f31329bc81b88a9 (patch)
tree9329fec6c43ca055e1a33c5bfa271e0e6cb2548f /internal
parent3137edfa7f576f058d120dfd8ec1037d16289e6d (diff)
HTTP: Add the body to status error
Diffstat (limited to 'internal')
-rw-r--r--internal/http/http.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/internal/http/http.go b/internal/http/http.go
index 3a81eb6..15e2a17 100644
--- a/internal/http/http.go
+++ b/internal/http/http.go
@@ -147,7 +147,7 @@ func HTTPMethodWithOpts(
if resp.StatusCode < 200 || resp.StatusCode > 299 {
// We make this a custom error because we want to extract the status code later
- statusErr := &HTTPStatusError{URL: url, Status: resp.StatusCode}
+ statusErr := &HTTPStatusError{URL: url, Body: string(body), Status: resp.StatusCode}
return resp.Header, body, &types.WrappedErrorMessage{Message: errorMessage, Err: statusErr}
}
@@ -157,14 +157,16 @@ func HTTPMethodWithOpts(
type HTTPStatusError struct {
URL string
+ Body string
Status int
}
func (e *HTTPStatusError) Error() string {
return fmt.Sprintf(
- "failed obtaining HTTP resource: %s as it gave an unsuccesful status code: %d",
+ "failed obtaining HTTP resource: %s as it gave an unsuccesful status code: %d. Body: %s",
e.URL,
e.Status,
+ e.Body,
)
}