Add details to Mural API errors (#4886)

This commit is contained in:
aecsocket
2025-12-11 12:49:59 +00:00
committed by GitHub
parent 3dd2de5f18
commit ddcc14d99f
8 changed files with 16 additions and 1 deletions

View File

@@ -161,6 +161,8 @@ pub enum ApiError {
RateLimitError(u128, u32),
#[error("Error while interacting with payment processor: {0}")]
Stripe(#[from] stripe::StripeError),
#[error(transparent)]
Mural(#[from] Box<muralpay::ApiError>),
}
impl ApiError {
@@ -201,6 +203,7 @@ impl ApiError {
Self::Stripe(..) => "stripe_error",
Self::TaxProcessor(..) => "tax_processor_error",
Self::Slack(..) => "slack_error",
Self::Mural(..) => "mural_error",
},
description: match self {
Self::Internal(e) => format!("{e:#?}"),
@@ -208,6 +211,10 @@ impl ApiError {
Self::Auth(e) => format!("{e:#?}"),
_ => self.to_string(),
},
details: match self {
Self::Mural(err) => serde_json::to_value(err.clone()).ok(),
_ => None,
},
}
}
}
@@ -249,6 +256,7 @@ impl actix_web::ResponseError for ApiError {
Self::Stripe(..) => StatusCode::FAILED_DEPENDENCY,
Self::TaxProcessor(..) => StatusCode::INTERNAL_SERVER_ERROR,
Self::Slack(..) => StatusCode::INTERNAL_SERVER_ERROR,
Self::Mural(..) => StatusCode::BAD_REQUEST,
}
}