From 1ef60b5cd32e8470806dad1c559c4953916fe6fd Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Mon, 23 Oct 2023 13:01:31 +0200 Subject: add Method, Target to type UnexpectedStatusCodeError --- errors.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'errors.go') diff --git a/errors.go b/errors.go index bee0b9f..06fa639 100644 --- a/errors.go +++ b/errors.go @@ -60,6 +60,8 @@ var ( // a response with the expected successful status code. The actual status code // can be checked with the Is() function; see documentation over there. type UnexpectedStatusCodeError struct { + Method string //e.g. http.MethodGet + Target string //either "" or "$CONTAINER_NAME" or "$CONTAINER_NAME/$OBJECT_NAME" ExpectedStatusCodes []int ActualResponse *http.Response ResponseBody []byte @@ -75,6 +77,11 @@ func (e UnexpectedStatusCodeError) Error() string { strings.Join(codeStrs, "/"), e.ActualResponse.StatusCode, ) + if e.Method != "" && e.Target != "" { + //NOTE: Method and Target were added in a minor version change, + //and may not be filled if `e` was constructed outside the library. + msg = fmt.Sprintf("could not %s %q in Swift: %s", e.Method, e.Target, msg) + } if len(e.ResponseBody) > 0 { msg += ": " + string(e.ResponseBody) } -- cgit v1.2.3