Skip to content
Discussion options

You must be logged in to vote

axum currently doesn’t have a way catch any possible error.

See https://github.com/tokio-rs/axum/tree/main/examples/customize-extractor-error for how to customize the response of extractors.

Generally you shouldn’t need to customize the response from Extension because that error should never reach the end user. That is always a programmer error that should be caught by your automated tests.

Id also recommend using https://docs.rs/axum/0.6.20/axum/struct.Router.html#method.with_state instead of Extension.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@antmelnyk
Comment options

Comment options

You must be logged in to vote
1 reply
@jojohanhannesnes
Comment options

Answer selected by jojohanhannesnes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants