1use std::path::PathBuf;
2
3use crate::page::PageId;
4
5#[derive(Debug, thiserror::Error)]
6pub enum ConfigError {
7 #[error("reading config '{path}'")]
8 Read {
9 path: PathBuf,
10 #[source]
11 source: std::io::Error,
12 },
13
14 #[error("parsing config '{path}'")]
15 Parse {
16 path: PathBuf,
17 #[source]
18 source: toml::de::Error,
19 },
20
21 #[error("unknown citation preset: '{0}'")]
22 UnknownPreset(String),
23
24 #[error("invalid citation pattern '{name}'")]
25 InvalidPattern {
26 name: String,
27 #[source]
28 source: regex_lite::Error,
29 },
30
31 #[error("config validation: {0}")]
32 Validation(String),
33}
34
35#[derive(Debug, thiserror::Error)]
36pub enum WikiError {
37 #[error("wiki root not found (searched ancestors of {start})")]
38 RootNotFound { start: PathBuf },
39
40 #[error("reading '{path}'")]
41 ReadFile {
42 path: PathBuf,
43 #[source]
44 source: std::io::Error,
45 },
46
47 #[error("writing '{path}'")]
48 WriteFile {
49 path: PathBuf,
50 #[source]
51 source: std::io::Error,
52 },
53
54 #[error("walking '{path}'")]
55 Walk {
56 path: PathBuf,
57 #[source]
58 source: ignore::Error,
59 },
60
61 #[error("parsing frontmatter in '{path}'")]
62 Frontmatter {
63 path: PathBuf,
64 #[source]
65 source: FrontmatterError,
66 },
67
68 #[error("page not found: {0}")]
69 PageNotFound(PageId),
70
71 #[error("duplicate page ID '{id}' in '{path1}' and '{path2}'")]
72 DuplicatePageId {
73 id: String,
74 path1: PathBuf,
75 path2: PathBuf,
76 },
77}
78
79#[derive(Debug, thiserror::Error)]
80pub enum FrontmatterError {
81 #[error("YAML parse error near '{context}'")]
82 Yaml {
83 #[source]
84 source: serde_yml::Error,
85 context: String,
86 },
87}
88
89#[derive(Debug, thiserror::Error)]
90pub enum RenameError {
91 #[error(transparent)]
92 Wiki(#[from] WikiError),
93
94 #[error("source page not found: {0}")]
95 SourceNotFound(PageId),
96
97 #[error("target page already exists: '{path}'")]
98 TargetExists { path: PathBuf },
99}
100
101#[derive(Debug, thiserror::Error)]
102pub enum LintError {
103 #[error(transparent)]
104 Wiki(#[from] WikiError),
105
106 #[error("{count} lint error(s) found")]
107 Failed { count: usize },
108}