config_tools/
error.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum Error {
5    AlreadyExists,
6    ConfigParse(String),
7    NotFound,
8    ConfigLoad(ini::Error),
9    ConfigCreation(std::io::Error),
10}
11
12impl fmt::Display for Error {
13    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14        match self {
15            Error::AlreadyExists => write!(f, "The key already exists"),
16            Error::ConfigParse(e) => write!(f, "Failed to parse config: {e}"),
17            Error::NotFound => write!(f, "The key was not found"),
18            Error::ConfigLoad(e) => write!(f, "Failed to load config file: {e:?}"),
19            Error::ConfigCreation(e) => write!(f, "Failed to create config file: {e:?}"),
20        }
21    }
22}