errorhandler , , . ,
@application.errorhandler(HTTPException)
def http_error_handler(error):
HTTP ( HTTP)
@application.errorhandler(Exception)
def http_error_handler(error):
: , TRAP_HTTP_EXCEPTIONS, (, app.config['TRAP_HTTP_EXCEPTIONS']=True).
() , , HTTPException, , errorhandler(n), n - HTTP; , HTTPException , errorhandler(c), c - .
,
app.config['TRAP_HTTP_EXCEPTIONS']=True
@application.errorhandler(Exception)
def http_error_handler(error):
, .
HTTPException HTTP (. ), 'TRAP_HTTP_EXCEPTIONS' , , .
, :
app.config['TRAP_HTTP_EXCEPTIONS']=True
@app.errorhandler(Exception)
def handle_error(e):
try:
if e.code < 400:
return flask.Response.force_type(e, flask.request.environ)
elif e.code == 404:
return make_error_page("Page Not Found", "The page you're looking for was not found"), 404
raise e
except:
return make_error_page("Error", "Something went wrong"), 500
, , , , , HTTP, . if e.code < 400 .. ( 500s, , )