77from models_library .rest_error import ErrorGet
88from servicelib .aiohttp import status
99from servicelib .logging_errors import create_troubleshotting_log_kwargs
10+ from servicelib .rabbitmq ._errors import RemoteMethodNotRegisteredError
1011from servicelib .rabbitmq .rpc_interfaces .catalog .errors import (
1112 CatalogForbiddenError ,
1213 CatalogItemNotFoundError ,
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