ProcessError processes an HTTP error by converting it if appropriate, and determining the HTTP status code to return.
(in error)
| 53 | // ProcessError processes an HTTP error by converting it if appropriate, and |
| 54 | // determining the HTTP status code to return. |
| 55 | func ProcessError(in error) (statusCode int, err error) { |
| 56 | statusCode, err = http.StatusInternalServerError, in |
| 57 | if ttnErr, ok := errors.From(err); ok { |
| 58 | statusCode = errors.ToHTTPStatusCode(ttnErr) |
| 59 | return statusCode, ttnErr |
| 60 | } |
| 61 | ttnErr := errors.FromHTTPStatusCode(statusCode, "message") |
| 62 | return statusCode, ttnErr.WithCause(err).WithAttributes("message", err.Error()) |
| 63 | } |
| 64 | |
| 65 | type errorHandlersKeyType struct{} |
| 66 |
no test coverage detected