#[non_exhaustive]pub enum PaymentError {
NotFound(Uuid),
Declined {
reason: String,
},
RefundFailed {
reason: String,
},
CurrencyMismatch {
expected: String,
got: String,
},
InvalidTransition(StateTransitionError<String>),
Other(Box<dyn Error + Send + Sync>),
}Expand description
Errors specific to payment operations.
§Example
use stateset_core::errors::PaymentError;
let err = PaymentError::not_found(uuid::Uuid::nil());
assert!(err.to_string().contains("not found"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
NotFound(Uuid)
Payment with the given ID was not found.
Declined
Payment was declined by the processor.
RefundFailed
Refund cannot be processed.
CurrencyMismatch
Currency mismatch between payment and order.
InvalidTransition(StateTransitionError<String>)
Invalid status transition for a payment.
Other(Box<dyn Error + Send + Sync>)
Extensibility.
Implementations§
Source§impl PaymentError
impl PaymentError
Sourcepub fn refund_failed(reason: impl Into<String>) -> Self
pub fn refund_failed(reason: impl Into<String>) -> Self
Convenience constructor for RefundFailed.
Sourcepub fn currency_mismatch(
expected: impl Into<String>,
got: impl Into<String>,
) -> Self
pub fn currency_mismatch( expected: impl Into<String>, got: impl Into<String>, ) -> Self
Convenience constructor for CurrencyMismatch.
Sourcepub fn invalid_transition(from: impl Display, to: impl Display) -> Self
pub fn invalid_transition(from: impl Display, to: impl Display) -> Self
Convenience constructor for InvalidTransition.
Trait Implementations§
Source§impl Debug for PaymentError
impl Debug for PaymentError
Source§impl Display for PaymentError
impl Display for PaymentError
Source§impl Error for PaymentError
impl Error for PaymentError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<PaymentError> for CommerceError
impl From<PaymentError> for CommerceError
Source§fn from(source: PaymentError) -> Self
fn from(source: PaymentError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for PaymentError
impl !UnwindSafe for PaymentError
impl Freeze for PaymentError
impl Send for PaymentError
impl Sync for PaymentError
impl Unpin for PaymentError
impl UnsafeUnpin for PaymentError
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
Mutably borrows from an owned value. Read more