Debian Codegraph @

lib/ansible/_internal/_templating/_errors.py

raw
1 from __future__ import annotations
2
3 from ansible.errors import AnsibleTemplatePluginError
4
5
6 class AnsibleTemplatePluginRuntimeError(AnsibleTemplatePluginError):
7 """The specified template plugin (lookup/filter/test) raised an exception during execution."""
8
9 def __init__(self, plugin_type: str, plugin_name: str) -> None:
10 super().__init__(f'The {plugin_type} plugin {plugin_name!r} failed.')
11
12
13 class AnsibleTemplatePluginLoadError(AnsibleTemplatePluginError):
14 """The specified template plugin (lookup/filter/test) failed to load."""
15
16 def __init__(self, plugin_type: str, plugin_name: str) -> None:
17 super().__init__(f'The {plugin_type} plugin {plugin_name!r} failed to load.')
18
19
20 class AnsibleTemplatePluginNotFoundError(AnsibleTemplatePluginError, KeyError):
21 """
22 The specified template plugin (lookup/filter/test) was not found.
23 This exception extends KeyError since Jinja filter/test resolution requires a KeyError to detect missing plugins.
24 Jinja compilation fails if a non-KeyError is raised for a missing filter/test, even if the plugin will not be invoked (inconsistent with stock Jinja).
25 """
26
27 def __init__(self, plugin_type: str, plugin_name: str) -> None:
28 super().__init__(f'The {plugin_type} plugin {plugin_name!r} was not found.')