TemplateError
struct TemplateErrorTyped error raised by :func:Template.compile / :func:Template.render.
Enumerated (_variant Int field) with comptime
aliases per condition. Equatable so callers can pattern-
match with e == TemplateError.UNTERMINATED_VAR etc. The
detail field carries human-readable extra context (the
offending tag name, the unbound variable name, the malformed
raw text, ...) — empty when the variant is self-explanatory.
Variants:
UNTERMINATED_VAR—{{ ... }}opener without a matching}}close.UNTERMINATED_TAG—{% ... %}opener without a matching%}close (or a{% endtag %}whose%}ran off the end of source).UNKNOWN_FILTER— unsupported filter after|in{{ name | filter }}. Only| safeis accepted.EMPTY_VAR—{{ }}or{{ | safe }}with no variable name.EMPTY_TAG—{% %}with no tokens.MALFORMED_IF—{% if %}not exactly one operand afterif.MALFORMED_FOR—{% for X in Y %}shape violated.detailcarries the raw token list.UNMATCHED_END—{% endif %}/{% endfor %}seen at the top level (no matching opener).detailcarries the unmatched tag head.UNKNOWN_TAG— unrecognised control tag in{% ... %}.detailcarries the tag head.UNBOUND_VARIABLE—{{ name }}for a name not inctx.strings.detailcarries the variable name.UNBOUND_ITERABLE—{% for x in name %}for a name not inctx.lists.detailcarries the variable name.UNKNOWN_NODE— internal: parsed tree contained a node kind the renderer doesn't handle. Should be unreachable unlessTemplateNode.kindwas constructed by hand.
Implements Copyable, Equatable, ImplicitlyCopyable, Movable, Writable
- Fields
detail: String
comptime UNTERMINATED_VAR = TemplateError(Int(1), String(""))comptime UNTERMINATED_TAG = TemplateError(Int(2), String(""))comptime UNKNOWN_FILTER = TemplateError(Int(3), String(""))comptime EMPTY_VAR = TemplateError(Int(4), String(""))comptime EMPTY_TAG = TemplateError(Int(5), String(""))comptime MALFORMED_IF = TemplateError(Int(6), String(""))comptime MALFORMED_FOR = TemplateError(Int(7), String(""))comptime UNMATCHED_END = TemplateError(Int(8), String(""))comptime UNKNOWN_TAG = TemplateError(Int(9), String(""))comptime UNBOUND_VARIABLE = TemplateError(Int(10), String(""))comptime UNBOUND_ITERABLE = TemplateError(Int(11), String(""))comptime UNKNOWN_NODE = TemplateError(Int(12), String(""))__eq__
def __eq__(self, other: Self) -> Bool Compare on the _variant tag only — detail is human-readable context, not part of the identity.
__ne__
def __ne__(self, other: Self) -> Bool variant_name
def variant_name(self) -> String write_to
def write_to[W: Writer](self, mut writer: W)