1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5 #[error("IO error: {0}")]
6 Io(#[from] std::io::Error),
7
8 #[error("Failed to parse frontmatter: {0}")]
9 FrontmatterParse(#[from] serde_yaml::Error),
10
11 #[error("Invalid entry file: {0}")]
12 InvalidEntry(String),
13
14 #[error("no .archelon directory found in current directory or any parent")]
15 JournalNotFound,
16
17 #[error("no entry found with id prefix `{0}`")]
18 EntryNotFound(String),
19
20 #[error("id prefix `{0}` is ambiguous ({1} matches)")]
21 AmbiguousId(String, usize),
22
23 #[error("{0} already exists")]
24 EntryAlreadyExists(String),
25
26 #[error("invalid config: {0}")]
27 InvalidConfig(String),
28}
29
30pub type Result<T> = std::result::Result<T, Error>;