-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Mastering Flask Web and API Development
By :

Chapter 1 showcased the use of the redirect()
method in rendering error pages given a status code, such as the status code 500
. We will now discuss a better way of managing exceptions and status codes, including triggering error pages per status code.
Flask applications must always implement an error-handling mechanism using any of the following strategies:
register_error_handler()
method.errorhandler
decorator.Exception
class.The declarative way to implement an error handler is to create a custom function and register it to the app
’s register_error_handler()
method. The custom function must have a single local parameter that will accept the injected error message from the platform. It must also return its assigned error page using the make_response...