Merge pull request #1142 from clarksun/patch-1
exception.md code sample miss 'async' prefix
This commit is contained in:
commit
bffed27bdb
|
@ -13,7 +13,7 @@ To throw an exception, simply `raise` the relevant exception from the
|
|||
from sanic.exceptions import ServerError
|
||||
|
||||
@app.route('/killme')
|
||||
def i_am_ready_to_die(request):
|
||||
async def i_am_ready_to_die(request):
|
||||
raise ServerError("Something bad happened", status_code=500)
|
||||
```
|
||||
|
||||
|
@ -24,7 +24,7 @@ from sanic.exceptions import abort
|
|||
from sanic.response import text
|
||||
|
||||
@app.route('/youshallnotpass')
|
||||
def no_no(request):
|
||||
async def no_no(request):
|
||||
abort(401)
|
||||
# this won't happen
|
||||
text("OK")
|
||||
|
@ -43,7 +43,7 @@ from sanic.response import text
|
|||
from sanic.exceptions import NotFound
|
||||
|
||||
@app.exception(NotFound)
|
||||
def ignore_404s(request, exception):
|
||||
async def ignore_404s(request, exception):
|
||||
return text("Yep, I totally found the page: {}".format(request.url))
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user