Better error logging
parent
1b1f6a3eee
commit
6919b2b6f0
|
@ -1143,7 +1143,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pic_ox"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
|
|
|
@ -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 => (
|
||||
|
|
Loading…
Reference in New Issue