From 31cecb5c905b7edfc2d689049bdf00c5601a9c47 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 7 Jan 2020 14:29:52 +0000 Subject: [PATCH] Show arguments of last function during error. --- app.py | 6 +++++- templates/show_error.html | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 525b23e..2598f0f 100755 --- a/app.py +++ b/app.py @@ -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): diff --git a/templates/show_error.html b/templates/show_error.html index bfadc50..0c7a9af 100644 --- a/templates/show_error.html +++ b/templates/show_error.html @@ -9,7 +9,11 @@

Software error: {{ tb.exception_type }}

-

{{ tb.exception }}

+
{{ tb.exception }}
+ +

Error in function "{{ tb.frames[-1].function_name }}": + {{ last_frame_args | pprint }}

+
{% set body %}