Module

template.error_enhancement

Template error enhancement — convert generic exceptions to TemplateRuntimeError.

Pure function: no Template state, no side effects.

Functions

_is_macro_iteration_error 1 bool
Return True only for iteration-specific MacroWrapper failures.
def _is_macro_iteration_error(error_str: str) -> bool
Parameters
Name Type Description
error_str str
Returns
bool
enhance_template_error 3 TemplateRuntimeError
Enhance a generic exception with template context from RenderContext. Converts…
def enhance_template_error(error: Exception, render_ctx: RenderContext, source: str | None) -> TemplateRuntimeError

Enhance a generic exception with template context from RenderContext.

Converts generic Python exceptions into TemplateRuntimeError with template name, line number, and source snippet context.

Parameters
Name Type Description
error Exception
render_ctx RenderContext
source str | None
Returns
TemplateRuntimeError