Skip to content

Commit a73fe95

Browse files
look for extended error codes when error body is unavailable
1 parent 83b12c3 commit a73fe95

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

api-error-response.go

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"fmt"
2424
"io"
2525
"net/http"
26+
"strings"
2627
)
2728

2829
/* **** SAMPLE ERROR RESPONSE ****
@@ -188,6 +189,15 @@ func httpRespToErrorResponse(resp *http.Response, bucketName, objectName string)
188189
}
189190
}
190191

192+
code := resp.Header.Get("x-minio-error-code")
193+
if code != "" {
194+
errResp.Code = code
195+
}
196+
desc := resp.Header.Get("x-minio-error-desc")
197+
if desc != "" {
198+
errResp.Message = strings.Trim(desc, `"`)
199+
}
200+
191201
// Save hostID, requestID and region information
192202
// from headers if not available through error XML.
193203
if errResp.RequestID == "" {

0 commit comments

Comments
 (0)