From 11a79a95dd9b2f2e0dd2d9dc999abd24f4ee232b Mon Sep 17 00:00:00 2001 From: Quentin Date: Fri, 15 Jan 2021 16:24:27 +0100 Subject: [PATCH] Simplify Error file --- src/web/error.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/web/error.rs b/src/web/error.rs index 220bacf..14bc3b7 100644 --- a/src/web/error.rs +++ b/src/web/error.rs @@ -12,16 +12,6 @@ pub enum Error { #[error(display = "Internal error: {}", _0)] InternalError(#[error(source)] GarageError), - #[error(display = "Internal error (Hyper error): {}", _0)] - Hyper(#[error(source)] hyper::Error), - - #[error(display = "Internal error (HTTP error): {}", _0)] - HTTP(#[error(source)] http::Error), - - // Category: cannot process - #[error(display = "Forbidden: {}", _0)] - Forbidden(String), - #[error(display = "Not found")] NotFound, @@ -29,9 +19,6 @@ pub enum Error { #[error(display = "Invalid UTF-8: {}", _0)] InvalidUTF8(#[error(source)] std::str::Utf8Error), - #[error(display = "Invalid XML: {}", _0)] - InvalidXML(#[error(source)] roxmltree::Error), - #[error(display = "Invalid header value: {}", _0)] InvalidHeader(#[error(source)] hyper::header::ToStrError), @@ -44,11 +31,8 @@ impl Error { match self { Error::NotFound => StatusCode::NOT_FOUND, Error::ApiError(e) => e.http_status_code(), - Error::Forbidden(_) => StatusCode::FORBIDDEN, Error::InternalError(GarageError::RPC(_)) => StatusCode::SERVICE_UNAVAILABLE, - Error::InternalError(_) | Error::Hyper(_) | Error::HTTP(_) => { - StatusCode::INTERNAL_SERVER_ERROR - } + Error::InternalError(_) => StatusCode::INTERNAL_SERVER_ERROR, _ => StatusCode::BAD_REQUEST, } }