mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-26 00:00:23 +02:00
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.
867 B
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: