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_EXCEPTIONSto True. If DEBUGequal False, but PROPAGATE_EXCEPTIONSthe default is False, and Flask returns 500for all errors ignored by registered errorhandlers. Setting PROPAGATE_EXCEPTIONSto Truecorrects error handling in this case.
What interests me is:
source
share