summaryrefslogtreecommitdiff
path: root/src/context.rs
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-07-27 17:46:28 +0200
committerJulian T <julian@jtle.dk>2021-07-27 17:46:28 +0200
commitf0648bcc4e7a6b7ce3f59013f25413a667dc507a (patch)
treea204f651e8fabb98953897f4c3b186ac89e57969 /src/context.rs
parentd7244c2cc7b8f62f2f42cca7f3dece89c30bf105 (diff)
Sort by timestamps and switch to thiserror crateHEADmaster
Diffstat (limited to 'src/context.rs')
-rw-r--r--src/context.rs50
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)
- }
-}