copier icon indicating copy to clipboard operation
copier copied to clipboard

Rewrite tracebacks to include template lines

Open johnslavik opened this issue 2 years ago • 2 comments

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.

johnslavik avatar Dec 08 '23 03:12 johnslavik

Does jinja have an option for that?

yajo avatar Dec 17 '23 23:12 yajo