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

Rewrite tracebacks to include template lines #1452

Open
bswck opened this issue Dec 8, 2023 · 1 comment
Open

Rewrite tracebacks to include template lines #1452

bswck opened this issue Dec 8, 2023 · 1 comment

Comments

@bswck
Copy link

bswck commented Dec 8, 2023

Actual Situation

I'm getting this traceback, because I messed something up:

Traceback (most recent call last):
  File "/home/bswck/.local/bin/copier", line 8, in <module>
    sys.exit(copier_app_run())
  [truncated a few lines]
  File "/home/bswck/.local/pipx/venvs/copier/lib/python3.8/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/tmp/copier.vcs.clone.mx4lwskc/project/#% if public %#CONTRIBUTING.md#% endif %#.jinja", line 3, in top-level template code
  File "/tmp/copier.vcs.clone.mx4lwskc/fragments/contributing.md", line 45, in top-level template code
  File "/tmp/copier.vcs.clone.mx4lwskc/fragments/guide.md", line 2, in top-level template code
TypeError: skeleton_notice() got an unexpected keyword argument 'sr'

But hm, I think this might be more informative.

Desired Situation

I would love to get such a traceback instead:

Traceback (most recent call last):
  File "/home/bswck/.local/bin/copier", line 8, in <module>
    sys.exit(copier_app_run())
  [truncated a few lines]
  File "/home/bswck/.local/pipx/venvs/copier/lib/python3.8/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/tmp/copier.vcs.clone.mx4lwskc/project/#% if public %#CONTRIBUTING.md#% endif %#.jinja", line 3, in top-level template code
+   The template line visible here.
  File "/tmp/copier.vcs.clone.mx4lwskc/fragments/contributing.md", line 45, in top-level template code
+   The template line visible here.
  File "/tmp/copier.vcs.clone.mx4lwskc/fragments/guide.md", line 2, in top-level template code
+   The failing template line visible here.
TypeError: skeleton_notice() got an unexpected keyword argument 'sr'
+ The information about ref of the failing template.
+ Maybe provide a URL to the template file in the given ref if it's "gh:"?

Proposed solution

If you like the suggestion, I can take it. Seems like an easy task.

@bswck bswck changed the title Rewrite tracebacks to include failing lines Rewrite tracebacks to include template lines Dec 8, 2023
@yajo
Copy link
Member

yajo commented Dec 17, 2023

Does jinja have an option for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants