python - How to get more information after overriding the method of flask's errorhandler (BaseError)
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-18 11:02:04
0
1
564

The reference article is this
http://www.qingpingshan.com/b...

Those errors that directly rewrite 404,500 are no problem
But if you want to use your own defined errors, it is not possible, and errors cannot trigger this errorhandler(BaseError)Customized errors

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
巴扎黑

I didn’t see your BaseError very specifically

But the best practice is generally like this:

Define an exception

# exceptions.py

class MyException(Exception):
    pass
# error_handlers.py

@app.errorhandler(MyException):
def handler_myexception(error):
    pass

are all defined, remember to import it in the appropriate place (for example, import it inside __init.py__) to let flask know that you have defined this Exception processing class.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template