aboutsummaryrefslogtreecommitdiff
path: root/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'errors.go')
-rw-r--r--errors.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/errors.go b/errors.go
index d4b3470..7a7d40d 100644
--- a/errors.go
+++ b/errors.go
@@ -49,11 +49,14 @@ func (e UnexpectedStatusCodeError) Error() string {
for idx, code := range e.ExpectedStatusCodes {
codeStrs[idx] = strconv.Itoa(code)
}
- return fmt.Sprintf("expected %s response, got %d instead: %s",
+ msg := fmt.Sprintf("expected %s response, got %d instead",
strings.Join(codeStrs, "/"),
e.ActualResponse.StatusCode,
- string(e.ResponseBody),
)
+ if len(e.ResponseBody) > 0 {
+ msg += ": " + string(e.ResponseBody)
+ }
+ return msg
}
//Is checks if the given error is an UnexpectedStatusCodeError for that status