#[non_exhaustive]pub enum Error {
Http {
provider: &'static str,
source: Error,
},
Gateway {
provider: &'static str,
code: i64,
message: String,
},
AmountMismatch {
expected: Amount,
actual: Amount,
},
Config(String),
Unsupported {
provider: &'static str,
operation: &'static str,
},
Decode {
provider: &'static str,
message: String,
},
}Expand description
Errors returned by gateway drivers.
Variants fall into three families:
- Transport —
Error::Httpwraps everyreqwestfailure (connection refused, TLS handshake, timeout, malformed response, …). - Gateway —
Error::Gatewayis returned when a provider’s API accepts the request but reports a business failure (insufficient funds, expired authority, blocked merchant, etc.). The containedcodeis the raw provider code; check provider docs to interpret. - Local —
Error::Config,Error::AmountMismatch,Error::Unsupportedare produced inside the SDK before/after the HTTP roundtrip.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Http
HTTP transport / serialisation failure.
Fields
Gateway
Gateway returned a business-level error.
code is the provider’s native error code; consult the provider’s
documentation to interpret it. message is the human-readable
message (often Persian).
Fields
AmountMismatch
Verification was attempted with an amount that doesn’t match what was originally charged. Almost always indicates someone tampered with the callback query string.
Fields
Config(String)
Configuration is invalid (missing merchant ID, malformed URL, etc.).
Unsupported
The provider does not support this operation (e.g. refunds via Pay.ir require a separate API contract).
Decode
Response decoding failed — the provider returned a payload we couldn’t match to the expected schema. Usually means the SDK is out of date relative to the provider’s API.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.