Skip to content

Commit 40502c5

Browse files
committed
🐛 Refactor: remove custom handler for DirectorServiceError and update error mapping
1 parent 540f786 commit 40502c5

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

services/web/server/src/simcore_service_webserver/director_v2/_controller/_rest_exceptions.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from aiohttp import web
21
from servicelib.aiohttp import status
3-
from servicelib.aiohttp.rest_responses import create_http_error
4-
from servicelib.aiohttp.web_exceptions_extension import get_http_error_class_or_none
52
from simcore_service_webserver.director_v2.exceptions import DirectorServiceError
63

74
from ...exception_handling import (
@@ -17,23 +14,6 @@
1714
_exceptions_handlers_map: ExceptionHandlersMap = {}
1815

1916

20-
async def _handler_director_service_error(
21-
request: web.Request, exception: Exception
22-
) -> web.Response:
23-
assert request # nosec
24-
25-
assert isinstance(exception, DirectorServiceError) # nosec
26-
return create_http_error(
27-
exception,
28-
reason=exception.reason,
29-
http_error_cls=get_http_error_class_or_none(exception.status)
30-
or web.HTTPServiceUnavailable,
31-
)
32-
33-
34-
_exceptions_handlers_map[DirectorServiceError] = _handler_director_service_error
35-
36-
3717
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
3818
UserDefaultWalletNotFoundError: HttpErrorInfo(
3919
status.HTTP_404_NOT_FOUND,
@@ -43,6 +23,10 @@ async def _handler_director_service_error(
4323
status.HTTP_402_PAYMENT_REQUIRED,
4424
"Wallet does not have enough credits for computations. {reason}",
4525
),
26+
DirectorServiceError: HttpErrorInfo(
27+
status.HTTP_503_SERVICE_UNAVAILABLE,
28+
"This service is currently not available. The incident was logged and will be investigated. Please try again later.",
29+
),
4630
}
4731

4832
_exceptions_handlers_map.update(to_exceptions_handlers_map(_TO_HTTP_ERROR_MAP))

0 commit comments

Comments
 (0)