diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..00dae56 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,28 @@ +//! Errors returned from functions in this crate. + +use std::path::PathBuf; + +#[derive(Debug, thiserror::Error)] +pub enum JournalError { + /// Configuration file does not exist. + #[error("specified configuration file does not exist: {0}")] + ConfigMissing(PathBuf), + + /// Failed to read the configuration file. + /// + /// This is for permission problems and such. + #[error("failed to read configuration file {0}")] + ReadConfig(PathBuf, #[source] std::io::Error), + + /// Configuration file has a syntax error. + #[error("failed to understand configuration file syntax: {0}")] + ConfigSyntax(PathBuf, #[source] serde_yaml::Error), + + /// The specified directory does not look like a journal. + #[error("directory {0} is not a journal")] + NotAJournal(String), + + /// Failed to create the directory for the journal. + #[error("failed to create journal directory {0}")] + CreateDirectory(PathBuf, #[source] std::io::Error), +} |