HomeDisk/utils/src/config/error.rs

33 lines
726 B
Rust
Raw Normal View History

2022-04-16 19:22:01 +00:00
use std::fmt;
#[derive(Debug)]
pub enum Error {
UnknowConfigDir(),
Io(std::io::Error),
Toml(toml::de::Error),
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
Error::Io(err)
}
}
impl From<toml::de::Error> for Error {
fn from(err: toml::de::Error) -> Self {
Error::Toml(err)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
2022-04-16 19:23:56 +00:00
Error::UnknowConfigDir() => {
write!(f, "failed to lock up a system configuration directory")
}
2022-04-16 19:22:01 +00:00
Error::Io(err) => write!(f, "{}", err),
Error::Toml(err) => write!(f, "{}", err),
}
}
}