diff --git a/app/__init__.py b/app/__init__.py index 75af97bd2..5ed77c29b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -430,7 +430,6 @@ def useful_headers_after_request(response): def register_errorhandlers(application): # noqa (C901 too complex) def _error_response(error_code): - application.logger.exception('Admin app errored with %s', error_code) resp = make_response(render_template("error/{0}.html".format(error_code)), error_code) return useful_headers_after_request(resp) @@ -469,19 +468,6 @@ def register_errorhandlers(application): # noqa (C901 too complex) def handle_no_permissions(error): return _error_response(401) - @application.errorhandler(500) - def handle_exception(error): - if current_app.config.get('DEBUG', None): - raise error - return _error_response(500) - - @application.errorhandler(Exception) - def handle_bad_request(error): - # We want the Flask in browser stacktrace - if current_app.config.get('DEBUG', None): - raise error - return _error_response(500) - @application.errorhandler(BadSignature) def handle_bad_token(error): # if someone has a malformed token @@ -509,6 +495,15 @@ def register_errorhandlers(application): # noqa (C901 too complex) ), 400) return useful_headers_after_request(resp) + @application.errorhandler(500) + @application.errorhandler(Exception) + def handle_bad_request(error): + current_app.logger.exception(error) + # We want the Flask in browser stacktrace + if current_app.config.get('DEBUG', None): + raise error + return _error_response(500) + def setup_event_handlers(): from flask_login import user_logged_in