dzl/
errors.rs

1use std::io;
2
3#[derive(Debug, Clone)]
4pub enum CustomError {
5    IOError(String),
6    ParseError(String),
7}
8
9impl From<io::Error> for CustomError {
10    fn from(e: io::Error) -> Self {
11        match e.kind() {
12            io::ErrorKind::NotFound => {
13                Self::IOError(String::from("Config file `Dzl.toml` not found"))
14            }
15            io::ErrorKind::PermissionDenied => Self::IOError(String::from(
16                "Permission denied, please check the config file's permissions",
17            )),
18            _ => Self::IOError(format!("Other IO errors: {:?}", e.kind())),
19        }
20    }
21}