HTTP exception thrown initiative
- abort method
- Throws a given state codes HTTPException or specify the response, for example, want to use a page not found exception to the termination request, you can call abort (404).
- parameter:
- code - HTTP error status code
# abort(404)
abort(500)
Thrown status code, you can only throw an error status code of the HTTP protocol
Capture error
- errorhandler decorator
- Register an error handler, when the program throws a specified error status code when the method is called decorator decorated
- parameter:
- code_or_exception - HTTP error status code or specified exception
- For example unitary status code of 500 error to the user-friendly tips:
app.errorhandler @ (500 ) DEF INTERNAL_SERVER_ERROR (E): return ' server move a '
- Capture the specified exception
app.errorhandler @ (the ZeroDivisionError) DEF zero_division_error (E): return ' divisor is not 0 '