(self)
| 21 | |
| 22 | impl IntoResponse for AppError { |
| 23 | fn into_response(self) -> Response { |
| 24 | let (status, message) = match &self { |
| 25 | AppError::NotFound(msg) => (StatusCode::NOT_FOUND, msg.clone()), |
| 26 | AppError::BadRequest(msg) => (StatusCode::BAD_REQUEST, msg.clone()), |
| 27 | AppError::Gone(msg) => (StatusCode::GONE, msg.clone()), |
| 28 | AppError::Internal(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg.clone()), |
| 29 | }; |
| 30 | |
| 31 | let body = json!({ |
| 32 | "error": message, |
| 33 | "status": status.as_u16(), |
| 34 | }); |
| 35 | |
| 36 | (status, Json(body)).into_response() |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | impl From<anyhow::Error> for AppError { |
nothing calls this directly
no outgoing calls
no test coverage detected