webserver_base/templates/
error.rs1use std::path::PathBuf;
4
5use handlebars::{RenderError, TemplateError as HandlebarsTemplateError};
6
7#[derive(Debug, thiserror::Error)]
9pub enum TemplateError {
10 #[error("failed to read template directory `{path}`")]
12 ReadDirectory {
13 path: PathBuf,
14 #[source]
15 source: std::io::Error,
16 },
17
18 #[error(
20 "`{path}` shadows the built-in `{name}` layout, which webserver-base \
21 embeds and every page extends. Rename it — a project may add any other \
22 layout, just not this one."
23 )]
24 ReservedName { name: &'static str, path: PathBuf },
25
26 #[error(
28 "`{path}` contains no `.hbs` pages. A frontend must serve at least one \
29 page; add `html/pages/home.hbs`."
30 )]
31 NoPages { path: PathBuf },
32
33 #[error(
35 "`{path}` is missing. Every frontend serves a 404, and its data is the \
36 same everywhere, so the library declares it — but the page itself is \
37 yours to design."
38 )]
39 MissingNotFoundPage { path: PathBuf },
40
41 #[error("failed to compile template `{name}`")]
43 Compile {
44 name: String,
45 #[source]
46 source: Box<HandlebarsTemplateError>,
47 },
48
49 #[error("failed to render template `{name}`")]
52 Render {
53 name: String,
54 #[source]
55 source: Box<RenderError>,
56 },
57
58 #[error("failed to serialize the JSON-LD document for page `{page}`")]
60 JsonLd {
61 page: String,
62 #[source]
63 source: serde_json::Error,
64 },
65
66 #[error("failed to serialize template data for page `{page}`")]
68 Serialize {
69 page: String,
70 #[source]
71 source: serde_json::Error,
72 },
73}