(self)
| 35 | |
| 36 | impl IntoResponse for AppError { |
| 37 | fn into_response(self) -> Response { |
| 38 | let (status, error_message) = match self { |
| 39 | AppError::Unauthorized(err) => (StatusCode::UNAUTHORIZED, err), |
| 40 | AppError::Forbidden(err) => (StatusCode::FORBIDDEN, err), |
| 41 | AppError::NotFound(err) => (StatusCode::NOT_FOUND, err), |
| 42 | AppError::MethodNotAllowed(err) => (StatusCode::METHOD_NOT_ALLOWED, err), |
| 43 | AppError::InternalServerError(err) => (StatusCode::INTERNAL_SERVER_ERROR, err), |
| 44 | AppError::NotAcceptable(err) => (StatusCode::NOT_ACCEPTABLE, err), |
| 45 | }; |
| 46 | |
| 47 | let body = Json(json!(error_message)); |
| 48 | (status, body).into_response() |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | impl std::fmt::Display for AppError { |
no outgoing calls
no test coverage detected