refactor(access_token): handle timeout errors gracefully (#1882)

This commit is contained in:
Narayan Bhat
2023-08-08 15:18:23 +05:30
committed by GitHub
parent c205f064b9
commit cc4136f85f
4 changed files with 55 additions and 8 deletions

View File

@ -186,7 +186,7 @@ pub fn http_not_implemented() -> actix_web::HttpResponse<BoxBody> {
.error_response()
}
#[derive(Debug, thiserror::Error)]
#[derive(Debug, thiserror::Error, PartialEq)]
pub enum ApiClientError {
#[error("Header map construction failed")]
HeaderMapConstructionFailed,
@ -315,6 +315,8 @@ pub enum ConnectorError {
MissingPaymentMethodType,
#[error("Balance in the payment method is low")]
InSufficientBalanceInPaymentMethod,
#[error("Server responded with Request Timeout")]
RequestTimeoutReceived,
}
#[derive(Debug, thiserror::Error)]
@ -490,6 +492,18 @@ pub enum WebhooksFlowError {
MissingRequiredField { field_name: &'static str },
}
impl ApiClientError {
pub fn is_upstream_timeout(&self) -> bool {
self == &Self::RequestTimeoutReceived
}
}
impl ConnectorError {
pub fn is_connector_timeout(&self) -> bool {
self == &Self::RequestTimeoutReceived
}
}
#[cfg(feature = "detailed_errors")]
pub mod error_stack_parsing {