use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum TemplateError {
UnclosedPlaceholder(String),
UnmatchedClosingBrace(String),
EmptyPlaceholder,
UnknownPlaceholder(String),
Render(String),
MissingVariable(String),
}
impl fmt::Display for TemplateError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::UnclosedPlaceholder(s) => write!(f, "unclosed placeholder in '{s}'"),
Self::UnmatchedClosingBrace(s) => {
write!(f, "unmatched closing placeholder brace in '{s}'")
}
Self::EmptyPlaceholder => write!(f, "placeholder cannot be empty"),
Self::UnknownPlaceholder(p) => write!(f, "unknown placeholder '{p}'"),
Self::Render(err) => write!(f, "template render failed: {err}"),
Self::MissingVariable(name) => write!(f, "missing template variable {name:?}"),
}
}
}
impl std::error::Error for TemplateError {}