#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Error(String);
impl Error {
pub fn new(msg: &str) -> Self {
Error(msg.to_string())
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl<T: std::error::Error + std::fmt::Debug + std::fmt::Display> From<T> for Error {
fn from(err: T) -> Self {
Error(format!("{}", err))
}
}
pub type Result<T> = std::result::Result<T, Error>;