Catching a 500 server error in Flask

后端 未结 6 1283
-上瘾入骨i
-上瘾入骨i 2021-02-01 12:41

I love Flask\'s error catching. It\'s beautifully simple:

@app.errorhandler(404)
def pageNotFound(error):
    return \"page not found\"

works

6条回答
  •  天涯浪人
    2021-02-01 13:25

    this code catching 500 status code and get exception error

    @app.errorhandler(Exception)
    def all_exception_handler(e):
        error = str(traceback.format_exc())
    

提交回复
热议问题