mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-25 00:00:23 +02:00
Add example
This commit is contained in:
@@ -29,6 +29,15 @@ pub enum Error {
|
||||
|
||||
#[error("request extension of type `{type_name}` was not set")]
|
||||
MissingExtension { type_name: &'static str },
|
||||
|
||||
#[error("`Content-Length` header is missing but was required")]
|
||||
LengthRequired,
|
||||
|
||||
#[error("response body was too large")]
|
||||
PayloadTooLarge,
|
||||
|
||||
#[error("response failed with status {0}")]
|
||||
WithStatus(StatusCode),
|
||||
}
|
||||
|
||||
impl From<Infallible> for Error {
|
||||
@@ -55,6 +64,11 @@ where
|
||||
| Error::QueryStringMissing
|
||||
| Error::DeserializeQueryString(_) => make_response(StatusCode::BAD_REQUEST),
|
||||
|
||||
Error::WithStatus(status) => make_response(status),
|
||||
|
||||
Error::LengthRequired => make_response(StatusCode::LENGTH_REQUIRED),
|
||||
Error::PayloadTooLarge => make_response(StatusCode::PAYLOAD_TOO_LARGE),
|
||||
|
||||
Error::MissingExtension { .. } | Error::SerializeResponseBody(_) => {
|
||||
make_response(StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user