critch/src/error.rs

31 lines
688 B
Rust

use std::fmt::Display;
#[derive(Debug)]
pub enum Error {
IOError(std::io::Error),
TOMLError(toml::de::Error),
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::IOError(error) => write!(f, "IO Error: {}", error),
Error::TOMLError(error) => write!(f, "TOML deserialization error: {}", error),
}
}
}
impl std::error::Error for Error {}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Self::IOError(e)
}
}
impl From<toml::de::Error> for Error {
fn from(e: toml::de::Error) -> Self {
Self::TOMLError(e)
}
}