mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-08 00:00:24 +02:00
Fix misplaced comment in error handling example (#3529)
This commit is contained in:
@@ -185,6 +185,7 @@ impl IntoResponse for AppError {
|
|||||||
let mut response = (status, AppJson(ErrorResponse { message })).into_response();
|
let mut response = (status, AppJson(ErrorResponse { message })).into_response();
|
||||||
if let Some(err) = err {
|
if let Some(err) = err {
|
||||||
// Insert our error into the response, our logging middleware will use this.
|
// Insert our error into the response, our logging middleware will use this.
|
||||||
|
// By wrapping the error in an Arc we can use it as an Extension regardless of any inner types not deriving Clone.
|
||||||
response.extensions_mut().insert(Arc::new(err));
|
response.extensions_mut().insert(Arc::new(err));
|
||||||
}
|
}
|
||||||
response
|
response
|
||||||
@@ -193,7 +194,6 @@ impl IntoResponse for AppError {
|
|||||||
|
|
||||||
impl From<JsonRejection> for AppError {
|
impl From<JsonRejection> for AppError {
|
||||||
fn from(rejection: JsonRejection) -> Self {
|
fn from(rejection: JsonRejection) -> Self {
|
||||||
// Arc enables cloning of a JsonRejection
|
|
||||||
Self::JsonRejection(rejection)
|
Self::JsonRejection(rejection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user