mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 18:24:12 +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),
|
||||
}
|
||||
|
||||
impl IntoResponse for Error {
|
||||
fn into_response(self) -> Response {
|
||||
impl Error {
|
||||
pub fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Error::NotFound => (StatusCode::NOT_FOUND, "not found").into_response(),
|
||||
e => format!("{:#}", e).into_response(),
|
||||
Error::NotFound => StatusCode::NOT_FOUND,
|
||||
_ => 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