Skip to content

Commit 0040fc5

Browse files
committed
cleanup
1 parent 6735374 commit 0040fc5

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

services/web/server/src/simcore_service_webserver/catalog/_controller_rest_exceptions.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from models_library.rest_error import ErrorGet
88
from servicelib.aiohttp import status
99
from servicelib.logging_errors import create_troubleshotting_log_kwargs
10+
from servicelib.rabbitmq._errors import RemoteMethodNotRegisteredError
1011
from servicelib.rabbitmq.rpc_interfaces.catalog.errors import (
1112
CatalogForbiddenError,
1213
CatalogItemNotFoundError,
@@ -37,7 +38,7 @@
3738
_logger = logging.getLogger(__name__)
3839

3940

40-
async def _handler_catalog_response_errors(
41+
async def _handler_catalog_client_errors(
4142
request: web.Request, exception: Exception
4243
) -> web.Response:
4344

@@ -73,13 +74,23 @@ async def _handler_catalog_response_errors(
7374
)
7475
)
7576
error = ErrorGet.model_construct(
76-
message=user_msg, support_id=oec, status=status_code
77+
message=user_msg,
78+
support_id=oec,
79+
status=status_code,
7780
)
7881

7982
return create_error_response(error, status_code=error.status)
8083

8184

8285
_TO_HTTP_ERROR_MAP: ExceptionToHttpErrorMap = {
86+
RemoteMethodNotRegisteredError: HttpErrorInfo(
87+
status.HTTP_503_SERVICE_UNAVAILABLE,
88+
MSG_CATALOG_SERVICE_UNAVAILABLE,
89+
),
90+
CatalogForbiddenError: HttpErrorInfo(
91+
status.HTTP_403_FORBIDDEN,
92+
"Forbidden catalog access",
93+
),
8394
CatalogItemNotFoundError: HttpErrorInfo(
8495
status.HTTP_404_NOT_FOUND,
8596
"Catalog item not found",
@@ -91,15 +102,12 @@ async def _handler_catalog_response_errors(
91102
DefaultPricingUnitForServiceNotFoundError: HttpErrorInfo(
92103
status.HTTP_404_NOT_FOUND, "Default pricing unit not found"
93104
),
94-
CatalogForbiddenError: HttpErrorInfo(
95-
status.HTTP_403_FORBIDDEN, "Forbidden catalog access"
96-
),
97105
}
98106

99107

100108
_exceptions_handlers_map: ExceptionHandlersMap = {
101-
CatalogResponseError: _handler_catalog_response_errors,
102-
CatalogConnectionError: _handler_catalog_response_errors,
109+
CatalogResponseError: _handler_catalog_client_errors,
110+
CatalogConnectionError: _handler_catalog_client_errors,
103111
}
104112
_exceptions_handlers_map.update(to_exceptions_handlers_map(_TO_HTTP_ERROR_MAP))
105113

0 commit comments

Comments
 (0)