1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
4pub enum VaultError {
5 #[error("'{0}' is not a directory")]
6 NotADirectory(PathBuf),
7 #[error("note already exists at '{0}'")]
8 NoteAlreadyExists(PathBuf),
9 #[error("note not found: '{0}'")]
10 NoteNotFound(String),
11 #[error("ambigous note identifier '{0}'; multiple matches found")]
12 AmbiguousNoteIdentifier(String, Vec<PathBuf>),
13 #[error("directory not found: {0}")]
14 DirectoryNotFound(PathBuf),
15 #[error("source note is the same as destination: '{0}'")]
16 MergeSourceIsDestination(PathBuf),
17 #[error("old-string not found in '{0}'")]
18 StringNotFound(PathBuf),
19 #[error("old-string found multiple times in '{0}'; must match exactly once")]
20 StringFoundMultipleTimes(PathBuf),
21 #[error(transparent)]
22 Io(#[from] std::io::Error),
23 #[error(transparent)]
24 Note(#[from] NoteError),
25 #[error(transparent)]
26 Search(#[from] SearchError),
27}
28
29#[derive(Debug, thiserror::Error)]
30pub enum NoteError {
31 #[error(transparent)]
32 Io(#[from] std::io::Error),
33 #[error("failed to serialize frontmatter: {0}")]
34 Yaml(#[from] serde_yaml::Error),
35 #[error("failed to serialize frontmatter: {0}")]
36 Json(String),
37 #[error("note body not loaded; use from_path_with_body() or load_body()")]
38 BodyNotLoaded,
39 #[error("'{0}' is not a valid note path")]
40 InvalidPath(PathBuf),
41 #[error("{0}")]
42 InvalidFieldName(String),
43}
44
45#[derive(Debug, thiserror::Error)]
46pub enum SearchError {
47 #[error("invalid glob pattern: '{0}'")]
48 InvalidGlob(#[from] globset::Error),
49 #[error("invalid regex pattern: '{0}'")]
50 InvalidRegex(#[from] regex::Error),
51}