Revamp error handling model (#402)

* Revamp error handling model

* changelog improvements and typo fixes

* Fix a few more Infallible bounds

* minor docs fixes
This commit is contained in:
David Pedersen
2021-10-24 17:33:03 +00:00
committed by GitHub
parent 1a78a3f224
commit f10508db0b
19 changed files with 501 additions and 558 deletions
+4 -4
View File
@@ -4,8 +4,8 @@
//! cargo run -p example-static-file-server
//! ```
use axum::{http::StatusCode, service, Router};
use std::{convert::Infallible, net::SocketAddr};
use axum::{error_handling::HandleErrorExt, http::StatusCode, service, Router};
use std::net::SocketAddr;
use tower_http::{services::ServeDir, trace::TraceLayer};
#[tokio::main]
@@ -23,10 +23,10 @@ async fn main() {
.nest(
"/static",
service::get(ServeDir::new(".")).handle_error(|error: std::io::Error| {
Ok::<_, Infallible>((
(
StatusCode::INTERNAL_SERVER_ERROR,
format!("Unhandled internal error: {}", error),
))
)
}),
)
.layer(TraceLayer::new_for_http());