pub use crate::exec::ExecError;
use std::{error::Error as StdError, fmt::Debug, num::TryFromIntError};
#[allow(missing_docs)] #[derive(thiserror::Error, Debug)]
pub enum SinkError {
#[error("Invalid message ID type. It has probably been copied from an incompatible sink type")]
InvalidMessageIdType(#[from] TryFromIntError),
#[error("Can't send via Telegram. Message contents: {msg:?}")]
Telegram {
source: teloxide::RequestError,
msg: Box<dyn Debug + Send + Sync>,
},
#[error("Can't send via Discord. Message contents: {msg:?}")]
Discord {
source: serenity::Error,
msg: Box<dyn Debug + Send + Sync>,
},
#[error("Can't pass message to a process")]
Exec(#[from] ExecError),
#[error("Error writing to stdout")]
Stdout(#[source] std::io::Error),
}
impl SinkError {
pub(crate) fn is_connection_err(&self) -> Option<&(dyn StdError + Send + Sync)> {
match self {
SinkError::Telegram {
source: teloxide::RequestError::Network(_),
..
} => Some(self),
_ => None,
}
}
}