From 6919b2b6f08d8536f296a37929d33191c54801bb Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Thu, 22 Feb 2024 19:13:57 -0700 Subject: [PATCH] Better error logging --- Cargo.lock | 2 +- src/api/models.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 262ab33..e5c84c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1143,7 +1143,7 @@ dependencies = [ [[package]] name = "pic_ox" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-trait", "axum", diff --git a/src/api/models.rs b/src/api/models.rs index 952b167..6d9003d 100644 --- a/src/api/models.rs +++ b/src/api/models.rs @@ -60,6 +60,7 @@ where } #[allow(dead_code)] +#[derive(Debug)] pub enum PicOxError { StoreError(StoreError), DbError(j_db::error::JDbError), @@ -88,18 +89,16 @@ pub struct ErrorResponse { impl IntoResponse for PicOxError { fn into_response(self) -> axum::response::Response { + error!("API Error: {:?}", self); let (status, message) = match self { PicOxError::StoreError(err) => match err { StoreError::InvalidFile => (StatusCode::BAD_REQUEST, err.to_string()), StoreError::OutOfStorage => (StatusCode::INSUFFICIENT_STORAGE, err.to_string()), StoreError::ImageTooBig => (StatusCode::UNAUTHORIZED, err.to_string()), - StoreError::IOError(e) => { - error!("IO error occurred handling request {}", e); - ( - StatusCode::INTERNAL_SERVER_ERROR, - "IO Error Has Occurred!".to_string(), - ) - } + StoreError::IOError(_) => ( + StatusCode::INTERNAL_SERVER_ERROR, + "IO Error Has Occurred!".to_string(), + ), }, PicOxError::DbError(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()), PicOxError::AlbumNotFound => (