You've already forked AstralRinth
forked from didirus/AstralRinth
Add details to Mural API errors (#4886)
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ pub async fn not_found() -> impl Responder {
|
||||
let data = ApiError {
|
||||
error: "not_found",
|
||||
description: "the requested route does not exist".to_string(),
|
||||
details: None,
|
||||
};
|
||||
|
||||
HttpResponse::NotFound().json(data)
|
||||
|
||||
@@ -151,6 +151,7 @@ impl actix_web::ResponseError for CreateError {
|
||||
CreateError::LimitReached => "limit_reached",
|
||||
},
|
||||
description: self.to_string(),
|
||||
details: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user