writeCustomErrorResponseJSON - similar to writeErrorResponseJSON, but accepts the error message directly (this allows messages to be dynamically generated.)
(ctx context.Context, w http.ResponseWriter, err APIError, errBody string, reqURL *url.URL, )
| 904 | // but accepts the error message directly (this allows messages to be |
| 905 | // dynamically generated.) |
| 906 | func writeCustomErrorResponseJSON(ctx context.Context, w http.ResponseWriter, err APIError, |
| 907 | errBody string, reqURL *url.URL, |
| 908 | ) { |
| 909 | reqInfo := logger.GetReqInfo(ctx) |
| 910 | errorResponse := APIErrorResponse{ |
| 911 | Code: err.Code, |
| 912 | Message: errBody, |
| 913 | Resource: reqURL.Path, |
| 914 | BucketName: reqInfo.BucketName, |
| 915 | Key: reqInfo.ObjectName, |
| 916 | RequestID: w.Header().Get(xhttp.AmzRequestID), |
| 917 | HostID: globalDeploymentID, |
| 918 | } |
| 919 | encodedErrorResponse := encodeResponseJSON(errorResponse) |
| 920 | writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeJSON) |
| 921 | } |
no test coverage detected