rskit_util/template/
error.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum TemplateError {
7 UnclosedPlaceholder(String),
9 UnmatchedClosingBrace(String),
11 EmptyPlaceholder,
13 UnknownPlaceholder(String),
15 Render(String),
17 MissingVariable(String),
19}
20
21impl fmt::Display for TemplateError {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 match self {
24 Self::UnclosedPlaceholder(s) => write!(f, "unclosed placeholder in '{s}'"),
25 Self::UnmatchedClosingBrace(s) => {
26 write!(f, "unmatched closing placeholder brace in '{s}'")
27 }
28 Self::EmptyPlaceholder => write!(f, "placeholder cannot be empty"),
29 Self::UnknownPlaceholder(p) => write!(f, "unknown placeholder '{p}'"),
30 Self::Render(err) => write!(f, "template render failed: {err}"),
31 Self::MissingVariable(name) => write!(f, "missing template variable {name:?}"),
32 }
33 }
34}
35
36impl std::error::Error for TemplateError {}