diff options
Diffstat (limited to 'src/context.rs')
-rw-r--r-- | src/context.rs | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/src/context.rs b/src/context.rs index f7b97ed..660c201 100644 --- a/src/context.rs +++ b/src/context.rs @@ -27,12 +27,28 @@ pub struct Options { pub url_prefix: Option<String>, } -#[derive(Debug)] +#[derive(Debug, thiserror::Error)] pub enum ConfigError { - Reading(io::Error), - Parsing(serde_yaml::Error), - CompilePattern(glob::PatternError), - CompileTemplate(tera::Error), + #[error("reading from file")] + Reading { + #[from] + source: io::Error, + }, + #[error("parsing config file")] + Parsing { + #[from] + source: serde_yaml::Error, + }, + #[error("compiling glob pattern")] + CompilePattern { + #[from] + source: glob::PatternError, + }, + #[error("compiling templates")] + CompileTemplate { + #[from] + source: tera::Error, + }, } #[derive(Deserialize, Debug, Serialize)] @@ -148,27 +164,3 @@ impl Config { } - -impl From<io::Error> for ConfigError { - fn from(error: io::Error) -> Self { - ConfigError::Reading(error) - } -} - -impl From<serde_yaml::Error> for ConfigError { - fn from(error: serde_yaml::Error) -> Self { - ConfigError::Parsing(error) - } -} - -impl From<glob::PatternError> for ConfigError { - fn from(error: glob::PatternError) -> Self { - ConfigError::CompilePattern(error) - } -} - -impl From<tera::Error> for ConfigError { - fn from(error: tera::Error) -> Self { - ConfigError::CompileTemplate(error) - } -} |