| 1. |
Describe Flask Error Handlers. |
|
Answer» In the Flask application, when an error occurs, an HTTP status CODE will be RETURNED. If the HTTP status code is between 400-499, that means the error occurs on the client-side data request. On the other hand, if the HTTP status code is between 500-599, then it means the error occurs on the server-side application. When an error occurs with an HTTP status code, we can SHOW custom error pages to the user with the help of error handlers. It can return responses when a certain type of error is occurred, which is similar to a function view that returns a response when the request URL is similar. It PASSES the object to handle the error, in most cases, it is an HTTPException. Another thing to note is that the response's HTTP status code is not set to the error handler's code. When returning a response from the error handler, we must make sure to include that. |
|