How to use handle_error in MethodRouter properly #1786
Answered
by
davidpdrsn
StarWishsama
asked this question in
Q&A
-
I wrote simple Router error handler like this: Router::new().route(
"/favicon.svg",
get_service(ServeFile::new("dashboard/favicon.svg"))
.handle_error(handle_error),
)
async fn handle_error(err: Error) -> impl IntoResponse {
return(StatusCode::INTERNAL_SERVER_ERROR, err.to_string())
} But got error:
|
Beta Was this translation helpful? Give feedback.
Answered by
davidpdrsn
Feb 25, 2023
Replies: 1 comment 4 replies
-
Are you using tower-http 0.4? If so you don't need to wrap it in |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
StarWishsama
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are you using tower-http 0.4? If so you don't need to wrap it in
get_service
and usehandle_error
at all. See https://github.com/tokio-rs/axum/blob/remove-spa-router/examples/static-file-server/src/main.rs