use std::fmt;
#[derive(Debug, Clone, PartialEq)]
pub enum ActorError {
ActorNotFound { id: u32 },
SendFailed { reason: String },
ReceiveFailed { reason: String },
ShutdownTimeout,
GuardianNotResponding,
InvalidState { reason: String },
ChannelError { reason: String },
}
impl fmt::Display for ActorError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ActorError::ActorNotFound { id } => {
write!(f, "Actor with ID {} not found", id)
}
ActorError::SendFailed { reason } => {
write!(f, "Failed to send message: {}", reason)
}
ActorError::ReceiveFailed { reason } => {
write!(f, "Failed to receive response: {}", reason)
}
ActorError::ShutdownTimeout => {
write!(f, "Actor system shutdown timed out")
}
ActorError::GuardianNotResponding => {
write!(f, "Guardian actor is not responding")
}
ActorError::InvalidState { reason } => {
write!(f, "Invalid actor state: {}", reason)
}
ActorError::ChannelError { reason } => {
write!(f, "Channel operation failed: {}", reason)
}
}
}
}
impl std::error::Error for ActorError {}
pub type ActorResult<T> = Result<T, ActorError>;