#[non_exhaustive]
#[derive(Debug)]
pub enum ChannelError {
Io(std::io::Error),
Malformed(String),
Unusable(String),
Closed,
AlreadyTaken,
}
impl core::fmt::Display for ChannelError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Io(error) => write!(f, "shepherd channel I/O failed: {error}"),
Self::Malformed(message) => write!(f, "malformed shepherd-channel frame: {message}"),
Self::Unusable(what) => write!(f, "unusable shepherd channel: {what}"),
Self::Closed => f.write_str("the shepherd channel is closed"),
Self::AlreadyTaken => f.write_str(
"the shepherd channel has already been taken by this process and can only be taken once",
),
}
}
}
impl core::error::Error for ChannelError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::Io(error) => Some(error),
_ => None,
}
}
}