1use std::path::PathBuf;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum ContentError {
6 #[error("empty content at {path}")]
7 EmptyContent { path: PathBuf },
8
9 #[error("missing frontmatter in {path}")]
10 MissingFrontmatter { path: PathBuf },
11
12 #[error("invalid frontmatter in {path}: {reason}")]
13 InvalidFrontmatter { path: PathBuf, reason: String },
14
15 #[error("missing required field 'title' in {path}")]
16 MissingTitle { path: PathBuf },
17}
18
19#[derive(Error, Debug)]
20pub enum ConfigError {
21 #[error("failed to read config file {path}: {source}")]
22 ReadError {
23 path: PathBuf,
24 source: std::io::Error,
25 },
26
27 #[error("failed to parse config file {path}: {reason}")]
28 ParseError { path: PathBuf, reason: String },
29}
30
31#[derive(Error, Debug)]
32pub enum RenderError {
33 #[error("template error: {0}")]
34 Template(String),
35
36 #[error("layout not found: {0}")]
37 LayoutNotFound(String),
38
39 #[error("serialization error: {0}")]
40 Serialization(#[from] serde_json::Error),
41}
42
43#[derive(Error, Debug)]
44pub enum BuildError {
45 #[error("content directory not found: {0}")]
46 ContentDirNotFound(PathBuf),
47
48 #[error("config error: {0}")]
49 Config(#[from] ConfigError),
50
51 #[error("content error: {0}")]
52 Content(#[from] ContentError),
53
54 #[error("render error: {0}")]
55 Render(#[from] RenderError),
56
57 #[error("io error: {0}")]
58 Io(#[from] std::io::Error),
59
60 #[error("search error: {0}")]
61 Search(String),
62}