# exceptions URL: /api/environment/exceptions/ Section: environment -------------------------------------------------------------------------------- exceptions - Kida window.BENGAL_THEME_DEFAULTS = { appearance: 'light', palette: 'brown-bengal' }; window.Bengal = window.Bengal || {}; window.Bengal.enhanceBaseUrl = '/kida/assets/js/enhancements'; window.Bengal.watchDom = true; window.Bengal.debug = false; window.Bengal.enhanceUrls = { 'toc': '/kida/assets/js/enhancements/toc.632a9783.js', 'docs-nav': '/kida/assets/js/enhancements/docs-nav.57e4b129.js', 'tabs': '/kida/assets/js/enhancements/tabs.aac9e817.js', 'lightbox': '/kida/assets/js/enhancements/lightbox.1ca22aa1.js', 'interactive': '/kida/assets/js/enhancements/interactive.fc077855.js', 'mobile-nav': '/kida/assets/js/enhancements/mobile-nav.d991657f.js', 'action-bar': '/kida/assets/js/enhancements/action-bar.d62417f4.js', 'copy-link': '/kida/assets/js/enhancements/copy-link.7d9a5c29.js', 'data-table': '/kida/assets/js/enhancements/data-table.1f5bc1eb.js', 'lazy-loaders': '/kida/assets/js/enhancements/lazy-loaders.a5c38245.js', 'holo': '/kida/assets/js/enhancements/holo.ee13c841.js', 'link-previews': '/kida/assets/js/enhancements/link-previews.8d906535.js' }; (function () { try { var defaults = window.BENGAL_THEME_DEFAULTS || { appearance: 'system', palette: '' }; var defaultAppearance = defaults.appearance; if (defaultAppearance === 'system') { defaultAppearance = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; } var storedTheme = localStorage.getItem('bengal-theme'); var storedPalette = localStorage.getItem('bengal-palette'); var theme = storedTheme ? (storedTheme === 'system' ? defaultAppearance : storedTheme) : defaultAppearance; var palette = storedPalette ?? defaults.palette; document.documentElement.setAttribute('data-theme', theme); if (palette) { document.documentElement.setAttribute('data-palette', palette); } } catch (e) { document.documentElement.setAttribute('data-theme', 'light'); } })(); { "prerender": [ { "where": { "and": [ { "href_matches": "/docs/*" }, { "not": { "selector_matches": "[data-external], [target=_blank], .external" } } ] }, "eagerness": "conservative" } ], "prefetch": [ { "where": { "and": [ { "href_matches": "/*" }, { "not": { "selector_matches": "[data-external], [target=_blank], .external" } } ] }, "eagerness": "conservative" } ] } Skip to main content Magnifying Glass ESC Recent Clear Magnifying Glass No results for "" Start typing to search... ↑↓ Navigate ↵ Open ESC Close Powered by Lunr )彡 DocumentationInfoAboutArrow ClockwiseGet StartedCodeSyntaxTerminalUsageNoteTutorialsStarburstExtendingBookmarkReferenceTroubleshootingReleasesDevGitHubKida API Reference Magnifying Glass Search ⌘K Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal List )彡 Magnifying Glass Search X Close Documentation Caret Down Info About Arrow Clockwise Get Started Code Syntax Terminal Usage Note Tutorials Starburst Extending Bookmark Reference Troubleshooting Releases Dev Caret Down GitHub Kida API Reference Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal Kida API Reference Caret Right Analysis analyzer cache config dependencies landmarks metadata purity roles Caret Right Compiler Caret Right Statements basic control_flow functions special_blocks template_structure variables _protocols coalescing core expressions utils Caret Right Environment core exceptions filters loaders protocols registry tests Caret Right Parser Caret Right Blocks control_flow core functions special_blocks template_structure variables _protocols core errors expressions statements tokens Caret Right Utils html lru_cache workers _types bytecode_cache kida lexer nodes template tstring Kida API ReferenceEnvironment ᗢ Caret Down Link Copy URL External Open LLM text Copy Copy LLM text Share with AI Ask Claude Ask ChatGPT Ask Gemini Ask Copilot Module environment.exceptions Exceptions for Kida template system. Exception Hierarchy: TemplateError (base) ├── TemplateNotFoundError # Template not found by loader ├── TemplateSyntaxError # Parse-time syntax error ├── TemplateRuntimeError # Render-time error with context │ ├── RequiredValueError # Required value was None/missing │ └── NoneComparisonError # Attempted None comparison (sorting) └── UndefinedError # Undefined variable access Error Messages: All exceptions provide rich error messages with: Source location (template name, line number) Expression context where error occurred Actual values and their types Actionable suggestions for fixing Example: ``` UndefinedError: Undefined variable 'titl' in article.html:5 Suggestion: Did you mean 'title'? Or use {{ titl | default('') }} ``` 7Classes Classes TemplateError 0 ▼ Base exception for all Kida template errors. All template-related exceptions inherit from this cla… Base exception for all Kida template errors. All template-related exceptions inherit from this class, enabling broad exception handling: >>> try: ... template.render() ... except TemplateError as e: ... log.error(f"Template error: {e}") TemplateNotFoundError 0 ▼ Template not found by any configured loader. Raised when `Environment.get_template(name)` cannot l… Template not found by any configured loader. Raised when Environment.get_template(name) cannot locate the template in any of the loader's search paths. TemplateSyntaxError 1 ▼ Parse-time syntax error in template source. Raised by the Parser when template syntax is invalid. … Parse-time syntax error in template source. Raised by the Parser when template syntax is invalid. Includes source location for error reporting. Methods Internal Methods 1 ▼ __init__ 4 ▼ def __init__(self, message: str, lineno: int | None = None, name: str | None = None, filename: str | None = None) Parameters Name Type Description message — lineno — Default: None name — Default: None filename — Default: None TemplateRuntimeError 7 ▼ Render-time error with rich debugging context. Raised during template rendering when an operation … Render-time error with rich debugging context. Raised during template rendering when an operation fails. Provides detailed information to help diagnose the issue: Template name and line number The expression that caused the error Actual values and their types Actionable suggestion for fixing Output Format: Runtime Error: 'NoneType' object has no attribute 'title' Location: article.html:15 Expression: {{ post.title }} Values: post = None (NoneType) Suggestion: Check if 'post' is defined, or use {{ post.title | default('') }} ``` Attributes Name Type Description message — Error description expression — Template expression that failed values — Dict of variable names → values for context template_name — Name of the template lineno — Line number in template source suggestion — Actionable fix suggestion Methods Internal Methods 1 ▼ __init__ 1 ▼ def __init__(self, message: str) Parameters Name Type Description message — RequiredValueError 1 ▼ A required value was None or missing. Raised by the `| require` filter when a value that must be p… A required value was None or missing. Raised by the | require filter when a value that must be present is None or missing. Useful for validating required context variables. Methods Internal Methods 1 ▼ __init__ 2 ▼ def __init__(self, field_name: str, message: str | None = None, **kwargs: Any) Parameters Name Type Description field_name — message — Default: None NoneComparisonError 1 ▼ Attempted to compare None values, typically during sorting. Raised when `| sort` or similar operat… Attempted to compare None values, typically during sorting. Raised when | sort or similar operations encounter None values that cannot be compared. Provides information about which items have None values for the sort attribute. Methods Internal Methods 1 ▼ __init__ 3 ▼ def __init__(self, left_value: Any, right_value: Any, attribute: str | None = None, **kwargs: Any) Parameters Name Type Description left_value — right_value — attribute — Default: None UndefinedError 1 ▼ Raised when accessing an undefined variable. Strict mode is enabled by default in Kida. When a tem… Raised when accessing an undefined variable. Strict mode is enabled by default in Kida. When a template references a variable that doesn't exist in the context, this error is raised instead of silently returning None. To fix: Pass the variable in render(): template.render(undefined_var="value") Use the default filter: {{ undefined_var | default("fallback") }} Methods Internal Methods 1 ▼ __init__ 3 ▼ def __init__(self, name: str, template: str | None = None, lineno: int | None = None) Parameters Name Type Description name — template — Default: None lineno — Default: None ← Previous environment Next → filters List © 2026 Kida built in ᓚᘏᗢ { "linkPreviews": { "enabled": true, "hoverDelay": 200, "hideDelay": 150, "showSection": true, "showReadingTime": true, "showWordCount": true, "showDate": true, "showTags": true, "maxTags": 3, "includeSelectors": [".prose"], "excludeSelectors": ["nav", ".toc", ".breadcrumb", ".pagination", ".card", "[class*='-card']", ".tab-nav", "[class*='-widget']", ".child-items", ".content-tiles"], "allowedHosts": [], "allowedSchemes": ["https"], "hostFailureThreshold": 3 } } window.BENGAL_LAZY_ASSETS = { tabulator: '/kida/assets/js/tabulator.min.js', dataTable: '/kida/assets/js/data-table.js', mermaidToolbar: '/kida/assets/js/mermaid-toolbar.9de5abba.js', mermaidTheme: '/kida/assets/js/mermaid-theme.344822c5.js', graphMinimap: '/kida/assets/js/graph-minimap.ff04e939.js', graphContextual: '/kida/assets/js/graph-contextual.355458ba.js' }; window.BENGAL_ICONS = { close: '/kida/assets/icons/close.911d4fe1.svg', enlarge: '/kida/assets/icons/enlarge.652035e5.svg', copy: '/kida/assets/icons/copy.3d56e945.svg', 'download-svg': '/kida/assets/icons/download.04f07e1b.svg', 'download-png': '/kida/assets/icons/image.c34dfd40.svg', 'zoom-in': '/kida/assets/icons/zoom-in.237b4a83.svg', 'zoom-out': '/kida/assets/icons/zoom-out.38857c77.svg', reset: '/kida/assets/icons/reset.d26dba29.svg' }; Arrow Up -------------------------------------------------------------------------------- Metadata: - Word Count: 1208 - Reading Time: 6 minutes