#[derive(Debug)]
pub enum Error {
IO(std::io::Error),
JSON(serde_json::Error),
Environment(std::env::VarError),
Message(String),
Generic(Box<dyn std::error::Error>)
}
impl From<&str> for Error {
fn from(s: &str) -> Self {
Self::Message(s.into())
}
}
impl From<String> for Error {
fn from(s: String) -> Self {
Self::Message(s)
}
}
impl From<std::io::Error> for Error {
fn from(error: std::io::Error) -> Self {
Self::IO(error)
}
}
impl From<serde_json::Error> for Error {
fn from(error: serde_json::Error) -> Self {
Self::JSON(error)
}
}
impl From<std::env::VarError> for Error {
fn from(error: std::env::VarError) -> Self {
Self::Environment(error)
}
}
pub type Result<T> = std::result::Result<T, Error>;