Skip to content

Commit 9c59a6e

Browse files
cmarquAA-Turner
andauthored
Print template path chain in TemplateNotFound exceptions (#11886)
Co-authored-by: Adam Turner <[email protected]>
1 parent 80d5396 commit 9c59a6e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Bugs fixed
6363
Patch by James Addison.
6464
* #11874: Configure a default 30-second value for ``linkcheck_timeout``.
6565
Patch by James Addison.
66+
* #11886: Print the Jinja2 template path chain in ``TemplateNotFound`` exceptions.
67+
Patch by Colin Marquardt.
6668

6769
Testing
6870
-------

sphinx/jinja2glue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,5 @@ def get_source(self, environment: Environment, template: str) -> tuple[str, str,
218218
return loader.get_source(environment, template)
219219
except TemplateNotFound:
220220
pass
221-
raise TemplateNotFound(template)
221+
msg = f"{template!r} not found in {self.environment.loader.pathchain}"
222+
raise TemplateNotFound(msg)

0 commit comments

Comments
 (0)