(self)
| 12 | |
| 13 | impl IntoResponse for Exception { |
| 14 | fn into_response(self) -> axum::response::Response { |
| 15 | let (status, error_message) = match self.0 { |
| 16 | ApplicationError::DatabaseConnectionError(err) => { |
| 17 | (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()) |
| 18 | } |
| 19 | ApplicationError::DeserializationError(err) => { |
| 20 | (StatusCode::BAD_REQUEST, err.to_string()) |
| 21 | } |
| 22 | |
| 23 | ApplicationError::InvalidURL => ( |
| 24 | StatusCode::BAD_REQUEST, |
| 25 | ApplicationError::InvalidURL.to_string(), |
| 26 | ), |
| 27 | command @ ApplicationError::EntityNotFound |
| 28 | | command @ ApplicationError::CommandNotFound |
| 29 | | command @ ApplicationError::EventNotFound => { |
| 30 | (StatusCode::NOT_FOUND, command.to_string()) |
| 31 | } |
| 32 | |
| 33 | ApplicationError::TransactionError => ( |
| 34 | StatusCode::BAD_GATEWAY, |
| 35 | ApplicationError::TransactionError.to_string(), |
| 36 | ), |
| 37 | ApplicationError::StopSentinel => ( |
| 38 | StatusCode::LOCKED, |
| 39 | ApplicationError::StopSentinel.to_string(), |
| 40 | ), |
| 41 | ApplicationError::ParsingError => ( |
| 42 | StatusCode::INTERNAL_SERVER_ERROR, |
| 43 | ApplicationError::ParsingError.to_string(), |
| 44 | ), |
| 45 | }; |
| 46 | let body = Json(json!({ "error": error_message })); |
| 47 | (status, body).into_response() |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | pub struct WebResponse<T>(pub T); |
nothing calls this directly
no outgoing calls
no test coverage detected