Skip to content

Commit

Permalink
cleanup and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Mar 18, 2024
1 parent 2272370 commit 521380e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ def _handle_http_successful(request: web.BaseRequest, err: web.HTTPSuccessful):

def _handle_as_internal_server_error(request: web.BaseRequest, err: Exception):
"""
This error handler is the last resource to catch unhandled exceptions and
are converted into web.HTTPInternalServerError (i.e. 500)
This error handler is the last resource to catch unhandled exceptions. When
an exception reaches this point, it is converted into a web.HTTPInternalServerError
reponse (i.e. HTTP_500_INTERNAL_ERROR) for the client and the server logs
the error to be diagnosed
Its purpose is:
- respond the client with 500 and a reference OEC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ async def raise_unexpected(cls, request: web.Request):

@classmethod
async def raise_exception(cls, request: web.Request):
for exc_cls in (NotImplementedError, asyncio.TimeoutError):
if exc_cls.__name__ == request.query["exc"]:
raise exc_cls
exc_name = request.query["exc"]
match exc_name:
case NotImplementedError.__name__:
raise NotImplementedError
case asyncio.TimeoutError.__name__:
raise asyncio.TimeoutError


@pytest.fixture
Expand Down

0 comments on commit 521380e

Please sign in to comment.