I use error handlers to catch and handle certain types of exceptions:
@app.errorhandler(CustomException)
def handle_custom_exception(error):
return redirect('redirect-path', code=301)
This works correctly if DEBUG
- True
, which implicitly sets PROPAGATE_EXCEPTIONS
to True
. If DEBUG
equal False
, but PROPAGATE_EXCEPTIONS
the default is False
, and Flask returns 500
for all errors ignored by registered errorhandler
s. Setting PROPAGATE_EXCEPTIONS
to True
corrects error handling in this case.
What interests me is:
source
share