Merge branch 'master' into app-passwords

This commit is contained in:
Jens Langhammer 2021-08-23 17:12:17 +02:00
commit 244dc671db
1 changed files with 12 additions and 5 deletions

View File

@ -19,10 +19,11 @@ class ASGIErrorHandler:
return await self.app(scope, receive, send)
except Exception as exc: # pylint: disable=broad-except
LOGGER.warning("Fatal ASGI exception", exc=exc)
return await self.error_handler(send)
return await self.error_handler(scope, send)
async def error_handler(self, send: Send) -> None:
async def error_handler(self, scope: Scope, send: Send) -> None:
"""Return a generic error message"""
if scope.get("scheme", "http") == "http":
return await send(
{
"type": "http.request",
@ -30,3 +31,9 @@ class ASGIErrorHandler:
"more_body": False,
}
)
return await send(
{
"type": "websocket.send",
"text": b"Internal server error",
}
)