| 1 |
""" |
| 2 |
This module contains generic exceptions used by template backends. Although, |
| 3 |
due to historical reasons, the Django template language also internally uses |
| 4 |
these exceptions, other exceptions specific to the DTL should not be added |
| 5 |
here. |
| 6 |
""" |
| 7 |
|
| 8 |
|
| 9 |
class TemplateDoesNotExist(Exception): |
| 10 |
""" |
| 11 |
The exception used when a template does not exist. Optional arguments: |
| 12 |
|
| 13 |
backend |
| 14 |
The template backend class used when raising this exception. |
| 15 |
|
| 16 |
tried |
| 17 |
A list of sources that were tried when finding the template. This |
| 18 |
is formatted as a list of tuples containing (origin, status), where |
| 19 |
origin is an Origin object or duck type and status is a string with the |
| 20 |
reason the template wasn't found. |
| 21 |
|
| 22 |
chain |
| 23 |
A list of intermediate TemplateDoesNotExist exceptions. This is used to |
| 24 |
encapsulate multiple exceptions when loading templates from multiple |
| 25 |
engines. |
| 26 |
""" |
| 27 |
|
| 28 |
def __init__(self, msg, tried=None, backend=None, chain=None): |
| 29 |
self.backend = backend |
| 30 |
if tried is None: |
| 31 |
tried = [] |
| 32 |
self.tried = tried |
| 33 |
if chain is None: |
| 34 |
chain = [] |
| 35 |
self.chain = chain |
| 36 |
super().__init__(msg) |
| 37 |
|
| 38 |
|
| 39 |
class TemplateSyntaxError(Exception): |
| 40 |
""" |
| 41 |
The exception used for syntax errors during parsing or rendering. |
| 42 |
""" |
| 43 |
|
| 44 |
pass |