Files
axum/src/docs/error_handling.md
T
David Pedersen 857ecd7314 Break root module docs into separate files (#432)
For 0.3 I'm thinking about some changes I wanna make to the docs. I
don't like how information is currently spread over so many places.
Still thinking about how I wanna re-organize it.

However I do think it makes sense to break the root module docs into
separate files that get included with `#![doc = include_str!("file")]`.
Makes working on a single section easier and more focused. It looks the
same for the user reading the docs.

This means axum's MSRV is now 1.54 but since thats two releases ago I'm
fine with that.
2021-10-31 20:37:56 +01:00

867 B

Error handling

In the context of axum an "error" specifically means if a [Service]'s response future resolves to Err(Service::Error). That means async handler functions can never fail since they always produce a response and their Service::Error type is [Infallible]. Returning statuses like 404 or 500 are not errors.

axum works this way because hyper will close the connection, without sending a response, if an error is encountered. This is not desireable so axum makes it impossible to forget to handle errors.

Sometimes you need to route to fallible services or apply fallible middleware in which case you need to handle the errors. That can be done using things from [error_handling].

You can find examples here: