use super::*;
impl StripeError {
pub const fn api(code: String, message: String, request_id: String) -> Self {
Self::Api {
code,
message,
request_id,
}
}
pub const fn code(&self) -> Option<&str> {
match self {
Self::Api { code, .. } => Some(code.as_str()),
_ => None,
}
}
pub const fn request_id(&self) -> Option<&str> {
match self {
Self::Api { request_id, .. } => Some(request_id.as_str()),
_ => None,
}
}
pub fn is_retryable(&self) -> bool {
match self {
Self::Transport(_) => true,
Self::Api { code, .. } => {
code == STRIPE_ERROR_RATE_LIMIT
|| code == STRIPE_ERROR_API_CONNECTION
|| code == STRIPE_ERROR_LOCK_TIMEOUT
}
_ => false,
}
}
}