From 8545b022f9c5cfe52d8eb3cca71ffde0a00bca6d Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 21 Jan 2019 10:29:34 +0100 Subject: [PATCH] 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. --- docs/exceptions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/exceptions.md b/docs/exceptions.md index 03908f86..5a7afd35 100644 --- a/docs/exceptions.md +++ b/docs/exceptions.md @@ -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