use std::{error, fmt, io};
#[derive(Debug)]
pub struct Error(pub String);
impl Error {
pub fn message(message: impl Into<String>) -> Self {
Self(message.into())
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.0)
}
}
impl error::Error for Error {}
impl From<io::Error> for Error {
fn from(value: io::Error) -> Self {
Self(value.to_string())
}
}
impl From<serde_json::Error> for Error {
fn from(value: serde_json::Error) -> Self {
Self(value.to_string())
}
}
pub type Result<T> = std::result::Result<T, Error>;