diff --git a/api/errors.go b/api/errors.go index a619193fc..4a7648a12 100644 --- a/api/errors.go +++ b/api/errors.go @@ -1633,7 +1633,7 @@ func GetAPIError(code ErrorCode) Error { // getErrorResponse gets in standard error and resource value and // provides a encodable populated response values. func getAPIErrorResponse(ctx context.Context, err error, resource, requestID, hostID string) ErrorResponse { - code := "BadRequest" + code := "InternalError" desc := err.Error() info := GetReqInfo(ctx) diff --git a/api/handler/list.go b/api/handler/list.go index 424359791..9b68bcd4f 100644 --- a/api/handler/list.go +++ b/api/handler/list.go @@ -2,7 +2,6 @@ package handler import ( "encoding/xml" - "errors" "net/http" "strconv" "time" @@ -120,18 +119,7 @@ func (h *handler) listObjects(w http.ResponseWriter, r *http.Request) (*listObje zap.String("request_id", rid), zap.Error(err)) - var s3Err api.Error - if ok := errors.As(err, &s3Err); ok { - api.WriteErrorResponse(r.Context(), w, s3Err, r.URL) - return nil, nil, err - } - - api.WriteErrorResponse(r.Context(), w, api.Error{ - Code: api.GetAPIError(api.ErrBadRequest).Code, - Description: err.Error(), - HTTPStatusCode: http.StatusBadRequest, - }, r.URL) - + api.WriteErrorResponse(r.Context(), w, err, r.URL) return nil, nil, err } diff --git a/api/response.go b/api/response.go index 88b961d66..f739198c2 100644 --- a/api/response.go +++ b/api/response.go @@ -119,7 +119,7 @@ var s3ErrorResponseMap = map[string]string{ // WriteErrorResponse writes error headers. func WriteErrorResponse(ctx context.Context, w http.ResponseWriter, err error, reqURL *url.URL) { - code := http.StatusBadRequest + code := http.StatusInternalServerError if e, ok := err.(Error); ok { code = e.HTTPStatusCode