icon_loader/theme_name_provider/
error.rs1use std::error::Error as StdError;
2use std::fmt;
3
4pub type Result<T> = std::result::Result<T, Error>;
6
7#[derive(Debug)]
9pub enum Error {
10 ConfigNotFound,
12
13 LoadConfig {
15 source: ini::Error,
17 },
18
19 ConfigMissingThemeName,
21
22 Custom {
24 source: Box<dyn StdError + Send + Sync>,
26 },
27}
28
29impl StdError for Error {
30 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
31 match self {
32 Error::LoadConfig { source } => Some(source),
33 Error::Custom { source } => Some(source.as_ref()),
34 _ => None,
35 }
36 }
37}
38
39impl fmt::Display for Error {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 match self {
42 Error::ConfigNotFound => write!(f, "Config file could not be found."),
43 Error::LoadConfig { source } => write!(f, "Error loading config file: {}", source),
44 Error::ConfigMissingThemeName => {
45 write!(f, "Config file is missing a valid theme name.")
46 }
47 Error::Custom { source } => {
48 write!(f, "Error in custom theme name provider: {}", source)
49 }
50 }
51 }
52}
53
54impl From<ini::Error> for Error {
55 fn from(source: ini::Error) -> Self {
56 Error::LoadConfig { source }
57 }
58}