Replace more anyhow errors with explicit error types

This commit is contained in:
Lennart
2024-06-01 14:24:31 +02:00
parent 943b964da0
commit 7dcc29302a
9 changed files with 31 additions and 20 deletions

View File

@@ -7,8 +7,8 @@ use thiserror::Error;
pub enum Error {
#[error("Not found")]
NotFound,
#[error("Bad request")]
BadRequest,
#[error("Bad request: {0}")]
BadRequest(String),
#[error("Unauthorized")]
Unauthorized,
#[error("Internal server error :(")]
@@ -25,7 +25,7 @@ impl actix_web::error::ResponseError for Error {
Self::InternalError => StatusCode::INTERNAL_SERVER_ERROR,
Self::Other(_) => StatusCode::INTERNAL_SERVER_ERROR,
Self::NotFound => StatusCode::NOT_FOUND,
Self::BadRequest => StatusCode::BAD_REQUEST,
Self::BadRequest(_) => StatusCode::BAD_REQUEST,
Self::Unauthorized => StatusCode::UNAUTHORIZED,
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
}