mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 10:14:13 +02:00
This commit is contained in:
parent
a6fe8ae5e0
commit
b3f0f8ff54
1 changed files with 11 additions and 4 deletions
15
src/error.rs
15
src/error.rs
|
|
@ -46,11 +46,18 @@ pub enum SetupError {
|
||||||
Other(String),
|
Other(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoResponse for Error {
|
impl Error {
|
||||||
fn into_response(self) -> Response {
|
pub fn status_code(&self) -> StatusCode {
|
||||||
match self {
|
match self {
|
||||||
Error::NotFound => (StatusCode::NOT_FOUND, "not found").into_response(),
|
Error::NotFound => StatusCode::NOT_FOUND,
|
||||||
e => format!("{:#}", e).into_response(),
|
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IntoResponse for Error {
|
||||||
|
fn into_response(self) -> Response {
|
||||||
|
let status_code = self.status_code();
|
||||||
|
(status_code, format!("{:#}", self)).into_response()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue