diff --git a/services/web/server/src/simcore_service_webserver/wallets/_handlers.py b/services/web/server/src/simcore_service_webserver/wallets/_handlers.py index 776d0389863..e7c67919f10 100644 --- a/services/web/server/src/simcore_service_webserver/wallets/_handlers.py +++ b/services/web/server/src/simcore_service_webserver/wallets/_handlers.py @@ -19,7 +19,7 @@ ) from servicelib.aiohttp.typing_extension import Handler from servicelib.error_codes import create_error_code -from servicelib.logging_utils import get_log_record_extra +from servicelib.logging_utils import LogExtra, get_log_record_extra from servicelib.request_keys import RQT_USERID_KEY from .._constants import RQ_PRODUCT_KEY @@ -90,17 +90,16 @@ async def wrapper(request: web.Request) -> web.StreamResponse: except BillingDetailsNotFoundError as exc: error_code = create_error_code(exc) - log_extra = {} + log_extra: LogExtra = {} if user_id := getattr(exc, "user_id", None): log_extra = get_log_record_extra(user_id=user_id) or {} + log_msg = f"{exc} [{error_code}]" _logger.exception( - "%s [%s]", - f"{exc}", - f"{error_code}", + log_msg, extra={"error_code": error_code, **log_extra}, ) - user_msg = MSG_BILLING_DETAILS_NOT_DEFINED_ERROR + f" ({error_code})" + user_msg = f"{MSG_BILLING_DETAILS_NOT_DEFINED_ERROR} ({error_code})" raise web.HTTPServiceUnavailable(reason=user_msg) from exc return wrapper