I would like to implement an exception handler for my Flask application that displays a custom error page when an Exception
is thrown. I can get this working easily with
@application.errorhandler(Exception)
def http_error_handler(error):
return flask.render_template('error.html', error=error), 500
but this has the side effect of catching all exceptions before they hit the debugger (either the Werkzeug debugger or my IDE's) so that debugging is effectively disabled.
How can I implement a custom exception handler that still allows be to debug exceptions and errors? Is there a way to disable my custom handler when in debug mode?