Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print template path chain in TemplateNotFound exception #11886

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Bugs fixed
Patch by James Addison.
* #11874: Configure a default 30-second value for ``linkcheck_timeout``.
Patch by James Addison.
* #11886: Print the Jinja2 template path chain in ``TemplateNotFound`` exceptions.
Patch by Colin Marquardt.

Testing
-------
Expand Down
3 changes: 2 additions & 1 deletion sphinx/jinja2glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,5 @@ def get_source(self, environment: Environment, template: str) -> tuple[str, str,
return loader.get_source(environment, template)
except TemplateNotFound:
pass
raise TemplateNotFound(template)
msg = f"{template!r} not found in {self.environment.loader.pathchain}"
raise TemplateNotFound(msg)