Skip to content

Commit 521380e

Browse files
committed
cleanup and doc
1 parent 2272370 commit 521380e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/service-library/src/servicelib/aiohttp/rest_middlewares.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ def _handle_http_successful(request: web.BaseRequest, err: web.HTTPSuccessful):
8181

8282
def _handle_as_internal_server_error(request: web.BaseRequest, err: Exception):
8383
"""
84-
This error handler is the last resource to catch unhandled exceptions and
85-
are converted into web.HTTPInternalServerError (i.e. 500)
84+
This error handler is the last resource to catch unhandled exceptions. When
85+
an exception reaches this point, it is converted into a web.HTTPInternalServerError
86+
reponse (i.e. HTTP_500_INTERNAL_ERROR) for the client and the server logs
87+
the error to be diagnosed
8688
8789
Its purpose is:
8890
- respond the client with 500 and a reference OEC

packages/service-library/tests/aiohttp/test_rest_middlewares.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ async def raise_unexpected(cls, request: web.Request):
140140

141141
@classmethod
142142
async def raise_exception(cls, request: web.Request):
143-
for exc_cls in (NotImplementedError, asyncio.TimeoutError):
144-
if exc_cls.__name__ == request.query["exc"]:
145-
raise exc_cls
143+
exc_name = request.query["exc"]
144+
match exc_name:
145+
case NotImplementedError.__name__:
146+
raise NotImplementedError
147+
case asyncio.TimeoutError.__name__:
148+
raise asyncio.TimeoutError
146149

147150

148151
@pytest.fixture

0 commit comments

Comments
 (0)