flowscope_core/templater/
error.rs

1//! Error types for the templating module.
2
3use thiserror::Error;
4
5/// Errors that can occur during template rendering.
6#[derive(Debug, Error)]
7pub enum TemplateError {
8    /// Template syntax is invalid (e.g., unclosed tags, invalid expressions).
9    #[error("template syntax error: {0}")]
10    SyntaxError(String),
11
12    /// A variable referenced in the template is undefined and has no default.
13    #[error("undefined variable: {0}")]
14    UndefinedVariable(String),
15
16    /// Template rendering failed for an unexpected reason.
17    #[error("render error: {0}")]
18    RenderError(String),
19}
20
21#[cfg(feature = "templating")]
22impl From<minijinja::Error> for TemplateError {
23    fn from(err: minijinja::Error) -> Self {
24        use minijinja::ErrorKind;
25
26        match err.kind() {
27            ErrorKind::SyntaxError => Self::SyntaxError(err.to_string()),
28            ErrorKind::UndefinedError => Self::UndefinedVariable(err.to_string()),
29            _ => Self::RenderError(err.to_string()),
30        }
31    }
32}