use super::status::TransferStatus;
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum TransferError {
OperatorMismatch { expected: String, got: String },
TransferAlreadyPending,
InvalidState {
current: TransferStatus,
action: String,
},
}
impl std::fmt::Display for TransferError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TransferError::OperatorMismatch { expected, got } => {
write!(f, "operator mismatch: expected {expected}, got {got}")
}
TransferError::TransferAlreadyPending => {
write!(f, "a transfer is already pending for this passport")
}
TransferError::InvalidState { current, action } => {
write!(f, "cannot {action}: transfer is in {current:?} state")
}
}
}
}
impl std::error::Error for TransferError {}