This commit is contained in:
Benny 2017-05-07 01:11:29 +08:00
parent 43c5a4bb60
commit 3f0e662358
2 changed files with 9 additions and 0 deletions

View File

@ -43,3 +43,11 @@ Some of the most useful exceptions are presented below:
usually occurs if there is an exception raised in user code. usually occurs if there is an exception raised in user code.
See the `sanic.exceptions` module for the full list of exceptions to throw. See the `sanic.exceptions` module for the full list of exceptions to throw.
You can also use `exceptions_base`, it can catch the exception just like
normal catching. It can be used for catching all unexpected error and eliminate
the risk that server information being stolen by attackers/
@app.exception_base(Exception)
def catch_everything(request, exception):
return text( "Server Error!",500)

View File

@ -18,6 +18,7 @@ from sanic.response import text, html
class ErrorHandler: class ErrorHandler:
handlers = None handlers = None
handlers_base = None
cached_handlers = None cached_handlers = None
_missing = object() _missing = object()