Skip to main content

TemplateError

Enum TemplateError 

Source
pub enum TemplateError {
    Io(Error),
    UndefinedVariable(String),
    Syntax(SyntaxError),
    MissingParams(Vec<String>),
    TypeMismatch {
        name: String,
        expected: String,
        actual: String,
        actual_value: String,
    },
    UnknownFilter(String),
    IncludeNotFound(String),
    DeclarationsMutated {
        details: String,
    },
    ExtraParams(Vec<String>),
    Panic(String),
}
Expand description

Errors produced by the template engine.

Variants§

§

Io(Error)

I/O error while loading a template file.

§

UndefinedVariable(String)

A referenced variable was not found in the context.

§

Syntax(SyntaxError)

Syntax error in the template.

§

MissingParams(Vec<String>)

Missing required parameters from frontmatter.

§

TypeMismatch

Type mismatch between declaration and value.

Fields

§name: String

Variable name.

§expected: String

The type declared in frontmatter.

§actual: String

The type found in the context.

§actual_value: String

Preview of the actual value for debugging.

§

UnknownFilter(String)

Unknown filter name.

§

IncludeNotFound(String)

Include file not found.

§

DeclarationsMutated

Parameter declarations were mutated at runtime.

Template frontmatter params: declarations are fixed at compile time. If a runtime-reloaded template has different declarations, this error is returned — the template body may be changed freely, but the parameter contract must remain stable.

Fields

§details: String

Human-readable description of what changed.

§

ExtraParams(Vec<String>)

Extra (undeclared) parameters were passed in the context.

The template engine is strict by default: only parameters declared in frontmatter may be passed. Use allow_extra_params on the render call to suppress this check.

§

Panic(String)

Template rendering halted by an explicit {% panic(...) %} statement.

Implementations§

Source§

impl TemplateError

Source

pub fn kind(&self) -> ErrorKind

Return the stable, data-independent ErrorKind of this error.

Unlike matching on the enum variants (which also carry payloads), this gives a lightweight, Copy discriminant that language bindings can map onto their own typed-error hierarchies without parsing the display message.

Trait Implementations§

Source§

impl Debug for TemplateError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for TemplateError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for TemplateError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for TemplateError

Source§

fn from(source: Error) -> TemplateError

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.