The error does not work when DEBUG False

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:

  • Can it be included PROPAGATE_EXCEPTIONSin production? Are there any side effects I should worry about?

  • Why does Flask have different default values ​​for this configuration in debug vs non-debug?

+4
source share

Source: https://habr.com/ru/post/1613721/


All Articles