Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/HH-238262' into EXP-102580
Browse files Browse the repository at this point in the history
  • Loading branch information
HH ReleaseBot committed Nov 16, 2024
2 parents 9f48053 + 154bc53 commit 273656c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontik/handler_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ async def send(message):
else:
raise RuntimeError(f'Unsupported response type "{message["type"]}" for asgi app')

await asgi_app(scope, receive, send)
try:
await asgi_app(scope, receive, send)
except Exception:
log.exception('failed to execute page')

return response

Expand Down
13 changes: 13 additions & 0 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ async def get_page(code: int = 200) -> None:
raise HTTPException(code)


class SomeException(Exception):
pass


@router.get('/some_exception')
async def some_exception_page() -> None:
raise SomeException()


class TestHttpError(FrontikTestBase):
@pytest.fixture(scope='class')
def frontik_app(self) -> FrontikApplication:
Expand All @@ -33,3 +42,7 @@ async def test_405(self):
response = await self.fetch('/http_exception', method='PUT')
assert response.status_code == 405
assert response.headers['allow'] == 'GET'

async def test_some_exception(self):
response = await self.fetch('/some_exception')
assert response.status_code == 500

0 comments on commit 273656c

Please sign in to comment.