1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::{error::Error, fmt::Display};
use crate::parser::SectionHeaderName;
#[allow(clippy::module_name_repetitions)]
#[derive(PartialEq, Eq, Hash, Clone, PartialOrd, Ord, Debug)]
pub enum GitConfigError<'a> {
SectionDoesNotExist(SectionHeaderName<'a>),
SubSectionDoesNotExist(Option<&'a str>),
KeyDoesNotExist,
FailedConversion,
}
impl Display for GitConfigError<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::SectionDoesNotExist(s) => write!(f, "Section '{}' does not exist.", s),
Self::SubSectionDoesNotExist(s) => match s {
Some(s) => write!(f, "Subsection '{}' does not exist.", s),
None => write!(f, "Top level section does not exist."),
},
Self::KeyDoesNotExist => write!(f, "The name for a value provided does not exist."),
Self::FailedConversion => write!(f, "Failed to convert to specified type."),
}
}
}
impl Error for GitConfigError<'_> {}