#[non_exhaustive]pub enum OrderError {
NotFound(Uuid),
CannotCancel {
status: String,
},
CannotRefund {
reason: String,
},
InvalidTransition(StateTransitionError<OrderStatusLabel>),
Other(Box<dyn Error + Send + Sync>),
}Expand description
Errors specific to order operations.
Use OrderError in domain logic that only touches orders. It converts
into CommerceError via #[from] so callers
working with the top-level result type get seamless interop.
§Example
use stateset_core::errors::OrderError;
use uuid::Uuid;
let err = OrderError::not_found(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)
Order with the given ID was not found.
CannotCancel
Order cannot be cancelled in its current status.
CannotRefund
Order cannot be refunded.
InvalidTransition(StateTransitionError<OrderStatusLabel>)
Invalid status transition for an order.
Other(Box<dyn Error + Send + Sync>)
Extensibility — domain callers can wrap arbitrary errors.
Implementations§
Source§impl OrderError
impl OrderError
Sourcepub fn cannot_cancel(status: impl Display) -> Self
pub fn cannot_cancel(status: impl Display) -> Self
Convenience constructor for CannotCancel.
Sourcepub fn cannot_refund(reason: impl Into<String>) -> Self
pub fn cannot_refund(reason: impl Into<String>) -> Self
Convenience constructor for CannotRefund.
Sourcepub fn invalid_transition(from: impl Display, to: impl Display) -> Self
pub fn invalid_transition(from: impl Display, to: impl Display) -> Self
Create an invalid transition error from display-able status values.
Trait Implementations§
Source§impl Debug for OrderError
impl Debug for OrderError
Source§impl Display for OrderError
impl Display for OrderError
Source§impl Error for OrderError
impl Error for OrderError
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<OrderError> for CommerceError
impl From<OrderError> for CommerceError
Source§fn from(source: OrderError) -> Self
fn from(source: OrderError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for OrderError
impl !UnwindSafe for OrderError
impl Freeze for OrderError
impl Send for OrderError
impl Sync for OrderError
impl Unpin for OrderError
impl UnsafeUnpin for OrderError
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