Better error logging
parent
1b1f6a3eee
commit
6919b2b6f0
|
@ -1143,7 +1143,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pic_ox"
|
name = "pic_ox"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
|
|
|
@ -60,6 +60,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum PicOxError {
|
pub enum PicOxError {
|
||||||
StoreError(StoreError),
|
StoreError(StoreError),
|
||||||
DbError(j_db::error::JDbError),
|
DbError(j_db::error::JDbError),
|
||||||
|
@ -88,18 +89,16 @@ pub struct ErrorResponse {
|
||||||
|
|
||||||
impl IntoResponse for PicOxError {
|
impl IntoResponse for PicOxError {
|
||||||
fn into_response(self) -> axum::response::Response {
|
fn into_response(self) -> axum::response::Response {
|
||||||
|
error!("API Error: {:?}", self);
|
||||||
let (status, message) = match self {
|
let (status, message) = match self {
|
||||||
PicOxError::StoreError(err) => match err {
|
PicOxError::StoreError(err) => match err {
|
||||||
StoreError::InvalidFile => (StatusCode::BAD_REQUEST, err.to_string()),
|
StoreError::InvalidFile => (StatusCode::BAD_REQUEST, err.to_string()),
|
||||||
StoreError::OutOfStorage => (StatusCode::INSUFFICIENT_STORAGE, err.to_string()),
|
StoreError::OutOfStorage => (StatusCode::INSUFFICIENT_STORAGE, err.to_string()),
|
||||||
StoreError::ImageTooBig => (StatusCode::UNAUTHORIZED, err.to_string()),
|
StoreError::ImageTooBig => (StatusCode::UNAUTHORIZED, err.to_string()),
|
||||||
StoreError::IOError(e) => {
|
StoreError::IOError(_) => (
|
||||||
error!("IO error occurred handling request {}", e);
|
|
||||||
(
|
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
"IO Error Has Occurred!".to_string(),
|
"IO Error Has Occurred!".to_string(),
|
||||||
)
|
),
|
||||||
}
|
|
||||||
},
|
},
|
||||||
PicOxError::DbError(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()),
|
PicOxError::DbError(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()),
|
||||||
PicOxError::AlbumNotFound => (
|
PicOxError::AlbumNotFound => (
|
||||||
|
|
Loading…
Reference in New Issue