mirror of https://github.com/encode/starlette.git
doc: exceptions: keep original status_code (#331)
It is considered to be best practice for a not-found page to also use status code 404. This changes the examples for the 404 and 500 pages to keep the exceptions status code.
This commit is contained in:
parent
24ac0b44fe
commit
8545b022f9
|
@ -16,11 +16,11 @@ app = Starlette()
|
|||
|
||||
@app.exception_handler(404)
|
||||
async def not_found(request, exc):
|
||||
return HTMLResponse(content=HTML_404_PAGE)
|
||||
return HTMLResponse(content=HTML_404_PAGE, status_code=exc.status_code)
|
||||
|
||||
@app.exception_handler(500)
|
||||
async def server_error(request, exc):
|
||||
return HTMLResponse(content=HTML_500_PAGE)
|
||||
return HTMLResponse(content=HTML_500_PAGE, status_code=exc.status_code)
|
||||
```
|
||||
|
||||
If `debug` is enabled and an error occurs, then instead of using the installed
|
||||
|
|
Loading…
Reference in New Issue