use std::path::PathBuf;
use handlebars::{RenderError, TemplateError as HandlebarsTemplateError};
#[derive(Debug, thiserror::Error)]
pub enum TemplateError {
#[error("failed to read template directory `{path}`")]
ReadDirectory {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error(
"`{path}` shadows the built-in `{name}` layout, which webserver-base \
embeds and every page extends. Rename it — a project may add any other \
layout, just not this one."
)]
ReservedName { name: &'static str, path: PathBuf },
#[error(
"`{path}` contains no `.hbs` pages. A frontend must serve at least one \
page; add `html/pages/home.hbs`."
)]
NoPages { path: PathBuf },
#[error(
"`{path}` is missing. Every frontend serves a 404, and its data is the \
same everywhere, so the library declares it — but the page itself is \
yours to design."
)]
MissingNotFoundPage { path: PathBuf },
#[error("failed to compile template `{name}`")]
Compile {
name: String,
#[source]
source: Box<HandlebarsTemplateError>,
},
#[error("failed to render template `{name}`")]
Render {
name: String,
#[source]
source: Box<RenderError>,
},
#[error("failed to serialize the JSON-LD document for page `{page}`")]
JsonLd {
page: String,
#[source]
source: serde_json::Error,
},
#[error("failed to serialize template data for page `{page}`")]
Serialize {
page: String,
#[source]
source: serde_json::Error,
},
}