You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exceptions.py 1.3KB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  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. class TemplateDoesNotExist(Exception):
  8. """
  9. The exception used when a template does not exist. Optional arguments:
  10. backend
  11. The template backend class used when raising this exception.
  12. tried
  13. A list of sources that were tried when finding the template. This
  14. is formatted as a list of tuples containing (origin, status), where
  15. origin is an Origin object or duck type and status is a string with the
  16. reason the template wasn't found.
  17. chain
  18. A list of intermediate TemplateDoesNotExist exceptions. This is used to
  19. encapsulate multiple exceptions when loading templates from multiple
  20. engines.
  21. """
  22. def __init__(self, msg, tried=None, backend=None, chain=None):
  23. self.backend = backend
  24. if tried is None:
  25. tried = []
  26. self.tried = tried
  27. if chain is None:
  28. chain = []
  29. self.chain = chain
  30. super().__init__(msg)
  31. class TemplateSyntaxError(Exception):
  32. """
  33. The exception used for syntax errors during parsing or rendering.
  34. """
  35. pass