MCPcopy Create free account
hub / github.com/Migorithm/rustiful-backend / into_response

Method into_response

bin/src/error.rs:14–48  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

12
13impl 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
51pub struct WebResponse<T>(pub T);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected