#[non_exhaustive]pub enum RazorpayError {
Http(Error),
Api(Box<ApiError>),
UnexpectedStatus {
http_status: StatusCode,
body: String,
},
InvalidUrl(String),
SignatureMismatch,
Decode(Error),
}Expand description
Everything that can go wrong in this crate.
The variants are kept distinct so retry logic can be written correctly — see
is_retryable.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Http(Error)
The request never completed — DNS, TLS, connection, or timeout failure.
Usually transient, so generally safe to retry for idempotent calls.
Api(Box<ApiError>)
Razorpay returned a structured error.
Boxed because it is by far the largest variant; inline it would put ~150
bytes on every Result the crate returns, including the overwhelmingly
common success path.
UnexpectedStatus
A non-2xx response that carried no parseable error envelope.
Typically a gateway or proxy failure returning HTML rather than JSON. The raw body is preserved instead of being reported as a misleading decode error.
InvalidUrl(String)
A request path could not be joined onto the base URL.
SignatureMismatch
A payment or webhook signature did not match.
Treat this as a forgery attempt: do not fulfil the order.
Decode(Error)
The response was not the shape this crate expected.
Means an API change or a bug in our types — never retryable, since the same request will produce the same undecodable response.
Implementations§
Source§impl RazorpayError
impl RazorpayError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the same request could plausibly succeed.
True for transport failures and 5xx/429 responses; false for client errors, signature mismatches, and decode failures, which will fail identically on a retry.
§Retrying is not automatically safe
This reports whether the server might answer differently, not whether the
call is safe to repeat. Retrying a POST /orders that actually succeeded
but timed out creates a duplicate order. Only retry non-idempotent
writes if you can deduplicate them yourself.
§Examples
if err.is_retryable() {
// back off and try again
}Sourcepub fn status(&self) -> Option<StatusCode>
pub fn status(&self) -> Option<StatusCode>
The HTTP status, when the error carries one.
Trait Implementations§
Source§impl Debug for RazorpayError
impl Debug for RazorpayError
Source§impl Display for RazorpayError
impl Display for RazorpayError
Source§impl Error for RazorpayError
impl Error for RazorpayError
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()