# error_enhancement

URL: /kida/api/template/error_enhancement/
Section: template
Description: Template error enhancement — convert generic exceptions to TemplateRuntimeError.

Pure function: no Template state, no side effects.

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/template/error_enhancement/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Ftemplate%2Ferror_enhancement%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Ftemplate%2Ferror_enhancement%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Ftemplate%2Ferror_enhancement%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Ftemplate%2Ferror_enhancement%2Findex.txt)

Module

#
`template.error_enhancement`

Template error enhancement — convert generic exceptions to TemplateRuntimeError.

Pure function: no Template state, no side effects.

2Functions

## 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`
