From fafac750baa70812432020784cc5ba2cc23224cc Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sun, 4 Feb 2018 23:29:09 +0100 Subject: add Container --- errors.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'errors.go') 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 -- cgit v1.2.3