aboutsummaryrefslogtreecommitdiff
path: root/errors.go
diff options
context:
space:
mode:
authorStefan Majewsky <stefan.majewsky@sap.com>2023-10-23 13:01:31 +0200
committerStefan Majewsky <stefan.majewsky@sap.com>2023-10-23 13:02:10 +0200
commit1ef60b5cd32e8470806dad1c559c4953916fe6fd (patch)
tree94b5a94a1a675a8839542bd57f535c994cbd7475 /errors.go
parent6067bcb956c78a38b12bb8f7a3b050a03bde97f0 (diff)
downloadgo-schwift-1ef60b5cd32e8470806dad1c559c4953916fe6fd.tar.gz
add Method, Target to type UnexpectedStatusCodeError
Diffstat (limited to 'errors.go')
-rw-r--r--errors.go7
1 files changed, 7 insertions, 0 deletions
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 "<account>" 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)
}