copier
copier copied to clipboard
Rewrite tracebacks to include template lines
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.
Does jinja have an option for that?