pub enum StripeError {
Api {
code: String,
message: String,
request_id: String,
},
Transport(String),
SignatureVerification(String),
Parse(StripeParseError),
Malformed(String),
}Expand description
A failure Stripe reported, or a transport failure on the way there.
Stripe’s REST errors carry a machine-readable code alongside the
human message. The request_id is what support asks for, so it
is kept as a distinct field rather than being folded into the
message.
Variants§
Api
Stripe answered with a structured error object.
Fields
Transport(String)
The request never reached Stripe, or the answer never came back.
SignatureVerification(String)
A webhook signature did not verify.
Parse(StripeParseError)
A core type could not be built from the given input.
Malformed(String)
The response body was not the JSON shape this crate expects.
Implementations§
Source§impl StripeError
impl StripeError
Sourcepub const fn code(&self) -> Option<&str>
pub const fn code(&self) -> Option<&str>
Return the machine-readable code when this is an API error.
§Returns
Option<&str>- Stripe’s error code, orNonefor the transport, parse and signature variants which have no code.
Sourcepub const fn request_id(&self) -> Option<&str>
pub const fn request_id(&self) -> Option<&str>
Return the request-id when this is an API error.
§Returns
Option<&str>- the request id to quote to Stripe support, orNonewhen the failure happened before Stripe responded.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Return whether retrying the same request could succeed.
A declined card is a settled answer, so retrying is pointless; a transport failure is not, so callers should back off and repeat.
§Returns
bool-truewhen the caller should retry with backoff.
Trait Implementations§
Source§impl Clone for StripeError
impl Clone for StripeError
Source§fn clone(&self) -> StripeError
fn clone(&self) -> StripeError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StripeError
impl Debug for StripeError
Source§impl Display for StripeError
impl Display for StripeError
impl Eq for StripeError
Source§impl Error for StripeError
impl Error for StripeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()