#[derive(Debug)]
pub enum MessageError {
SendFailed(String),
OtherError(String),
}
impl std::fmt::Display for MessageError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
MessageError::SendFailed(msg) => write!(f, "Failed to send message: {}", msg),
MessageError::OtherError(msg) => write!(f, "Error: {}", msg),
}
}
}
impl std::error::Error for MessageError {}
impl<T> From<tokio::sync::mpsc::error::SendError<T>> for MessageError {
fn from(_: tokio::sync::mpsc::error::SendError<T>) -> Self {
MessageError::SendFailed("Channel closed".into())
}
}