Skip to content

Commit

Permalink
log unhandled errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckHend committed Jul 11, 2024
1 parent c248fd4 commit f9afcb7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions inference-gateway/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// All internal errors map to PlatformError
// PlatformError maps to ErrorResponse

use log;
use serde::ser::SerializeMap;
use serde::Serialize;
use sqlx::error::Error as DbError;
Expand Down Expand Up @@ -75,7 +76,7 @@ pub enum PlatformError {
S3Error(String),
}

// PUBLIC FACING ERROR RESPOSNES
// PUBLIC FACING ERROR RESPONSES
#[derive(Error, Debug)]
pub enum ErrorResponse {
#[error("{0}")]
Expand Down Expand Up @@ -110,9 +111,13 @@ impl ResponseError for PlatformError {
PlatformError::NotFoundError(_) => ErrorResponse::NotFound(self.to_string()),
PlatformError::InvalidQuery(_) => ErrorResponse::BadRequest(self.to_string()),
PlatformError::ValueError(_) => ErrorResponse::BadRequest(self.to_string()),
_ => ErrorResponse::InternalServerError(
"Internal Server Error. Please contact support".to_string(),
),
_ => {
// log the error locally
log::error!("Unhandled Error: {:?}", self.to_string());
ErrorResponse::InternalServerError(
"Internal Server Error. Please contact support".to_string(),
)
}
};
HttpResponse::build(self.status_code()).json(resp)
}
Expand Down

0 comments on commit f9afcb7

Please sign in to comment.