Skip to content

Commit

Permalink
implement IntoResponse for RequestProcessorError
Browse files Browse the repository at this point in the history
  • Loading branch information
juan518munoz committed Oct 23, 2024
1 parent aff1048 commit 680a207
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions core/node/eigenda_proxy/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use axum::response::{IntoResponse, Response};
use axum::{
http::StatusCode,
response::{IntoResponse, Response},
};

#[derive(Debug, PartialEq)]
pub enum MemStoreError {
Expand All @@ -24,6 +27,21 @@ pub(crate) enum RequestProcessorError {

impl IntoResponse for RequestProcessorError {
fn into_response(self) -> Response {
unimplemented!("EigenDA request error into response")
let (status_code, message) = match self {
RequestProcessorError::EigenDA(err) => {
tracing::error!("EigenDA error: {:?}", err);
match err {
EigenDAError::TlsError => (StatusCode::BAD_GATEWAY, "Tls error".to_owned()),
EigenDAError::UriError => (StatusCode::BAD_GATEWAY, "Uri error".to_owned()),
EigenDAError::ConnectionError(err) => (
StatusCode::BAD_GATEWAY,
format!("Connection error: {:?}", err).to_owned(),
),
EigenDAError::PutError => (StatusCode::BAD_GATEWAY, "Put error".to_owned()),
EigenDAError::GetError => (StatusCode::BAD_GATEWAY, "Get error".to_owned()),
}
}
};
(status_code, message).into_response()
}
}

0 comments on commit 680a207

Please sign in to comment.