MCPcopy
hub / github.com/pallets/jinja / TemplatesNotFound

Class TemplatesNotFound

src/jinja2/exceptions.py:53–85  ·  view source on GitHub ↗

Like :class:`TemplateNotFound` but raised if multiple templates are selected. This is a subclass of :class:`TemplateNotFound` exception, so just catching the base exception will catch both. .. versionchanged:: 2.11 If a name in the list of names is :class:`Undefined`, a message

Source from the content-addressed store, hash-verified

51
52
53class TemplatesNotFound(TemplateNotFound):
54 """Like :class:`TemplateNotFound` but raised if multiple templates
55 are selected. This is a subclass of :class:`TemplateNotFound`
56 exception, so just catching the base exception will catch both.
57
58 .. versionchanged:: 2.11
59 If a name in the list of names is :class:`Undefined`, a message
60 about it being undefined is shown rather than the empty string.
61
62 .. versionadded:: 2.2
63 """
64
65 def __init__(
66 self,
67 names: t.Sequence[t.Union[str, "Undefined"]] = (),
68 message: t.Optional[str] = None,
69 ) -> None:
70 if message is None:
71 from .runtime import Undefined
72
73 parts = []
74
75 for name in names:
76 if isinstance(name, Undefined):
77 parts.append(name._undefined_message)
78 else:
79 parts.append(name)
80
81 parts_str = ", ".join(map(str, parts))
82 message = f"none of the templates given were found: {parts_str}"
83
84 super().__init__(names[-1] if names else None, message)
85 self.templates = list(names)
86
87
88class TemplateSyntaxError(TemplateError):

Callers 1

select_templateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected