Show arguments of last function during error.

This commit is contained in:
Edward Betts 2020-01-07 14:29:52 +00:00
parent 412d4e1a18
commit 31cecb5c90
2 changed files with 10 additions and 2 deletions

6
app.py
View file

@ -15,6 +15,7 @@ from sqlalchemy.orm import aliased
from sqlalchemy.sql.expression import desc
from collections import defaultdict
from datetime import datetime
import inspect
import itertools
import hashlib
import json
@ -79,7 +80,10 @@ def shutdown_session(exception=None):
@app.errorhandler(InternalServerError)
def exception_handler(e):
tb = get_current_traceback()
return render_template('show_error.html', tb=tb), 500
last_frame_args = inspect.getargs(tb.frames[-1].code)
return render_template('show_error.html',
tb=tb,
last_frame_args=last_frame_args), 500
@app.template_global()
def set_url_args(endpoint=None, **new_args):

View file

@ -9,7 +9,11 @@
<h1>Software error: {{ tb.exception_type }}</h1>
<div>
<p>{{ tb.exception }}</p>
<pre>{{ tb.exception }}</pre>
<p>Error in function "{{ tb.frames[-1].function_name }}":
{{ last_frame_args | pprint }}</p>
</div>
{% set body %}