summaryrefslogtreecommitdiff
path: root/src/error.rs
blob: 00dae5644345423e3143786bc2309ba64f7c1d4e (plain)
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
//! 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),
}