use std::fmt;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CommandDispatchError {
Rejected(String),
Unroutable(String),
Transport(String),
DeadlineExceeded,
Handler(String),
}
impl fmt::Display for CommandDispatchError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Rejected(reason) => write!(formatter, "command rejected: {reason}"),
Self::Unroutable(reason) => write!(formatter, "command unroutable: {reason}"),
Self::Transport(reason) => write!(formatter, "command transport error: {reason}"),
Self::DeadlineExceeded => write!(formatter, "command dispatch deadline exceeded"),
Self::Handler(reason) => write!(formatter, "command handler error: {reason}"),
}
}
}
impl std::error::Error for CommandDispatchError {}