use std::fmt;
#[derive(Clone, Debug, PartialEq)]
pub enum Error {
NoSuchComponent,
NoSuchMethod,
Failed(String),
UnexpectedReply(String),
ProgramNotFound(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::NoSuchComponent => f.write_str("no such component"),
Error::NoSuchMethod => f.write_str("no such method"),
Error::Failed(reason) => f.write_str(reason),
Error::UnexpectedReply(what) => write!(f, "unexpected reply: {what}"),
Error::ProgramNotFound(name) => write!(f, "{name}: command not found"),
}
}
}
impl std::error::Error for Error {}
pub type Result<T> = std::result::Result<T, Error>;