config_tools/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::fmt;

#[derive(Debug)]
pub enum Error {
    AlreadyExists,
    ConfigParse(String),
    NotFound,
    ConfigLoad(ini::Error),
    ConfigCreation(std::io::Error),
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Error::AlreadyExists => write!(f, "The key already exists"),
            Error::ConfigParse(e) => write!(f, "Failed to parse config: {e}"),
            Error::NotFound => write!(f, "The key was not found"),
            Error::ConfigLoad(e) => write!(f, "Failed to load config file: {e:?}"),
            Error::ConfigCreation(e) => write!(f, "Failed to create config file: {e:?}"),
        }
    }
}