Show locals in last frame during traceback.

This commit is contained in:
Edward Betts 2020-01-07 14:40:15 +00:00
parent 19c4a7d221
commit 849aa57780
2 changed files with 7 additions and 4 deletions

4
app.py
View file

@ -80,9 +80,11 @@ def shutdown_session(exception=None):
@app.errorhandler(InternalServerError)
def exception_handler(e):
tb = get_current_traceback()
last_frame_args = inspect.getargs(tb.frames[-1].code)
last_frame = tb.frames[-1]
last_frame_args = inspect.getargs(last_frame.code)
return render_template('show_error.html',
tb=tb,
last_frame=last_frame,
last_frame_args=last_frame_args), 500
@app.template_global()

View file

@ -11,9 +11,10 @@
<div>
<pre>{{ tb.exception }}</pre>
<p>Error in function "{{ tb.frames[-1].function_name }}":
{{ last_frame_args | pprint }}</p>
<p>Error in function "{{ tb.frames[-1].function_name }}"<br>
{{ last_frame_args | pprint }}<br>
locals: {{ last_frame.locals | pprint }}
<p>
</div>
{% set body %}