From 23cf79911e20eac981a25dc1c2f839d37f98c296 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 21 Nov 2022 12:11:38 +0100 Subject: Add fields for users --- server/src/errors.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'server/src/errors.rs') diff --git a/server/src/errors.rs b/server/src/errors.rs index e541eda..72eb837 100644 --- a/server/src/errors.rs +++ b/server/src/errors.rs @@ -7,14 +7,12 @@ use serde_json::json; /// All errors raised by the web app pub enum AppError { - /// Generic error, never called yet - Generic, /// Database error Database, /// Generic bad request. It is handled with a message value BadRequest(String), /// Not found error - NotFound, + NotFound(String), /// Raised when a token is not good created TokenCreation, /// Raised when a passed token is not valid @@ -30,16 +28,12 @@ impl IntoResponse for AppError { /// ``` fn into_response(self) -> Response { let (status, error_message) = match self { - AppError::Generic => ( - StatusCode::INTERNAL_SERVER_ERROR, - "Generic error, can't find why".to_string(), - ), AppError::Database => ( StatusCode::INTERNAL_SERVER_ERROR, "Error with database connection".to_string(), ), AppError::BadRequest(value) => (StatusCode::BAD_REQUEST, value), - AppError::NotFound => (StatusCode::NOT_FOUND, "Element not found".to_string()), + AppError::NotFound(value) => (StatusCode::NOT_FOUND, value), AppError::TokenCreation => ( StatusCode::INTERNAL_SERVER_ERROR, "Token creation error".to_string(), -- cgit v1.2.3-18-g5258