Limit HTTP request verbosity
@@ -292,13 +292,20 @@ func (r *Requester) DoRequest(req *http.Request, method, path string, headers ma
}
if resp.StatusCode != 200 && resp.StatusCode != 201 && resp.StatusCode != 202 {
- return fmt.Errorf("Error: HTTP Status code %s. Body: %s", resp.Status, contents)
+ err = fmt.Errorf("unsuccessful HTTP status code: %d", resp.StatusCode)
+
+ if verbose {
+ err = fmt.Errorf("%s\n%s", err.Error(),
+ fmt.Sprintf("%s exchange raw response: %s", r.Name, string(contents)))
+ }
+
+ return err
}
resp.Body.Close()
if verbose {
log.Printf("HTTP status: %s, Code: %v", resp.Status, resp.StatusCode)
- log.Printf("%s exchange raw response: %s", r.Name, string(contents[:]))
+ log.Printf("%s exchange raw response: %s", r.Name, string(contents))
}
if result != nil {
