Skip to content

Commit 573c17b

Browse files
committed
renaming
1 parent fb47d63 commit 573c17b

File tree

15 files changed

+88
-80
lines changed

15 files changed

+88
-80
lines changed

packages/service-library/src/servicelib/aiohttp/rest_middlewares.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def _process_and_raise_unexpected_error(request: web.BaseRequest, err: Exception
7070
)
7171
_logger.exception(
7272
**create_troubleshotting_log_kwargs(
73-
message_to_user=frontend_msg,
74-
exception=err,
73+
error_user_msg=frontend_msg,
74+
error=err,
7575
error_context=error_context,
7676
)
7777
)

packages/service-library/src/servicelib/logging_errors.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212

1313
def create_troubleshotting_log_message(
14-
message_to_user: str,
15-
exception: BaseException,
14+
error_user_msg: str,
15+
error: BaseException,
1616
error_code: ErrorCodeStr,
1717
error_context: dict[str, Any] | None = None,
1818
tip: str | None = None,
@@ -28,16 +28,16 @@ def create_troubleshotting_log_message(
2828
"""
2929
debug_data = pformat(
3030
{
31-
"exception_type": f"{type(exception)}",
32-
"exception_details": f"{exception}",
31+
"exception_type": f"{type(error)}",
32+
"exception_details": f"{error}",
3333
"error_code": error_code,
3434
"context": pformat(error_context, indent=1),
3535
"tip": tip,
3636
},
3737
indent=1,
3838
)
3939

40-
return f"{message_to_user}.\n{debug_data}"
40+
return f"{error_user_msg}.\n{debug_data}"
4141

4242

4343
class LogKwargs(TypedDict):
@@ -46,8 +46,8 @@ class LogKwargs(TypedDict):
4646

4747

4848
def create_troubleshotting_log_kwargs(
49-
message_to_user: str,
50-
exception: BaseException,
49+
error_user_msg: str,
50+
error: BaseException,
5151
error_context: dict[str, Any] | None = None,
5252
tip: str | None = None,
5353
) -> LogKwargs:
@@ -61,25 +61,25 @@ def create_troubleshotting_log_kwargs(
6161
except MyException as exc
6262
_logger.exception(
6363
**create_troubleshotting_log_kwargs(
64-
message_to_user=frontend_msg,
64+
error_user_msg=frontend_msg,
6565
exception=exc,
6666
tip="Check row in `groups_extra_properties` for this product. It might be missing.",
6767
)
6868
)
6969
7070
"""
7171
# error-code
72-
error_code = create_error_code(exception)
72+
error_code = create_error_code(error)
7373

7474
# error-context
7575
context = error_context or {}
76-
if isinstance(exception, OsparcErrorMixin):
77-
context.update(exception.error_context())
76+
if isinstance(error, OsparcErrorMixin):
77+
context.update(error.error_context())
7878

7979
# aggregate
8080
log_msg = create_troubleshotting_log_message(
81-
message_to_user=message_to_user,
82-
exception=exception,
81+
error_user_msg=error_user_msg,
82+
error=error,
8383
error_code=error_code,
8484
error_context=context,
8585
tip=tip,

services/api-server/src/simcore_service_api_server/exceptions/handlers/_handlers_factory.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,19 @@ async def _http_error_handler(
3131
assert request # nosec
3232
assert isinstance(exception, exception_cls) # nosec
3333

34-
msg = error_message
34+
user_error_msg = error_message
3535
if add_exception_to_message:
36-
msg += f" {exception}"
36+
user_error_msg += f" {exception}"
3737

3838
if add_oec_to_message:
3939
error_code = create_error_code(exception)
40-
msg += f" [{error_code}]"
40+
user_error_msg += f" [{error_code}]"
4141

4242
_logger.exception(
4343
**create_troubleshotting_log_kwargs(
44-
f"Unexpected {exception.__class__.__name__}: {msg}",
45-
exception=exception,
44+
user_error_msg, error=exception, tip="Unexpected error"
4645
)
4746
)
48-
return create_error_json_response(msg, status_code=status_code)
47+
return create_error_json_response(user_error_msg, status_code=status_code)
4948

5049
return _http_error_handler

services/api-server/src/simcore_service_api_server/services/log_streaming.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,17 @@ async def log_generator(self) -> AsyncIterable[str]:
133133

134134
except Exception as exc: # pylint: disable=W0718
135135
error_code = create_error_code(exc)
136-
error_msg = MSG_INTERNAL_ERROR_USER_FRIENDLY_TEMPLATE + f" [{error_code}]"
136+
user_error_msg = (
137+
MSG_INTERNAL_ERROR_USER_FRIENDLY_TEMPLATE + f" [{error_code}]"
138+
)
137139

138140
_logger.exception(
139141
**create_troubleshotting_log_kwargs(
140-
error_msg,
141-
exception=exc,
142+
user_error_msg,
143+
error=exc,
142144
)
143145
)
144-
yield ErrorGet(errors=[error_msg]).json() + _NEW_LINE
146+
yield ErrorGet(errors=[user_error_msg]).json() + _NEW_LINE
145147

146148
finally:
147149
await self._log_distributor.deregister(self._job_id)

services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_observer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,16 @@ async def observing_single_service(
145145

146146
# With unhandled errors, let's generate and ID and send it to the end-user
147147
# so that we can trace the logs and debug the issue.
148-
front_end_msg = (
148+
user_error_msg = (
149149
f"This service ({service_name}) unexpectedly failed."
150150
" Our team has recorded the issue and is working to resolve it as quickly as possible."
151151
" Thank you for your patience."
152152
)
153153

154154
logger.exception(
155155
**create_troubleshotting_log_kwargs(
156-
front_end_msg,
157-
exception=e,
156+
user_error_msg,
157+
error=e,
158158
error_context={
159159
"service_name": service_name,
160160
"user_id": scheduler_data.user_id,
@@ -165,7 +165,7 @@ async def observing_single_service(
165165
error_code = create_error_code(e)
166166
scheduler_data.dynamic_sidecar.status.update_failing_status(
167167
# This message must be human-friendly
168-
front_end_msg,
168+
user_error_msg,
169169
error_code,
170170
)
171171
finally:

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ async def async_command(
108108
except Exception as err: # pylint: disable=broad-except
109109

110110
error_code = create_error_code(err)
111-
error_msg = f"Unexpected error [{error_code}]"
111+
user_error_msg = f"Unexpected error [{error_code}]"
112112
_logger.exception(
113113
**create_troubleshotting_log_kwargs(
114-
error_msg,
115-
exception=err,
114+
user_error_msg,
115+
error=err,
116116
error_context={"command": command, "proc.returncode": proc.returncode},
117117
tip="Process with command failed unexpectily",
118118
)
119119
)
120120

121121
return CommandResult(
122122
success=False,
123-
message=error_msg,
123+
message=user_error_msg,
124124
command=f"{command}",
125125
elapsed=time.time() - start,
126126
)

services/payments/src/simcore_service_payments/services/notifier_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ async def _create_user_email(
241241
_logger.exception(
242242
**create_troubleshotting_log_kwargs(
243243
"Cannot attach invoice to payment",
244-
exception=exc,
244+
error=exc,
245245
error_context={
246246
"user": user,
247247
"payment": payment,

services/web/server/src/simcore_service_webserver/login/_registration.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,35 +214,35 @@ def _invitations_request_context(invitation_code: str) -> Iterator[URL]:
214214

215215
except (ValidationError, InvalidInvitationError) as err:
216216
error_code = create_error_code(err)
217-
front_end_msg = (
217+
user_error_msg = (
218218
f"Invalid invitation. {MSG_INVITATIONS_CONTACT_SUFFIX} [{error_code}]"
219219
)
220220

221221
_logger.exception(
222222
**create_troubleshotting_log_kwargs(
223-
front_end_msg,
224-
exception=err,
223+
user_error_msg,
224+
error=err,
225225
tip="Something went wrong with the invitation",
226226
)
227227
)
228228
raise web.HTTPForbidden(
229-
reason=front_end_msg,
229+
reason=user_error_msg,
230230
content_type=MIMETYPE_APPLICATION_JSON,
231231
) from err
232232

233233
except InvitationsServiceUnavailableError as err:
234234
error_code = create_error_code(err)
235-
front_end_msg = f"Unable to process your invitation since the invitations service is currently unavailable [{error_code}]"
235+
user_error_msg = f"Unable to process your invitation since the invitations service is currently unavailable [{error_code}]"
236236

237237
_logger.exception(
238238
**create_troubleshotting_log_kwargs(
239-
front_end_msg,
240-
exception=err,
239+
user_error_msg,
240+
error=err,
241241
tip="Something went wrong communicating the `invitations` service",
242242
)
243243
)
244244
raise web.HTTPServiceUnavailable(
245-
reason=front_end_msg,
245+
reason=user_error_msg,
246246
content_type=MIMETYPE_APPLICATION_JSON,
247247
) from err
248248

services/web/server/src/simcore_service_webserver/login/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def wrapper(request: web.Request) -> web.StreamResponse:
3535
front_end_msg = MSG_2FA_UNAVAILABLE_OEC.format(error_code=exc.error_code())
3636
# in these cases I want to log the cause
3737
_logger.exception(
38-
**create_troubleshotting_log_kwargs(front_end_msg, exception=exc)
38+
**create_troubleshotting_log_kwargs(front_end_msg, error=exc)
3939
)
4040
raise web.HTTPServiceUnavailable(
4141
reason=front_end_msg,

services/web/server/src/simcore_service_webserver/login/handlers_confirmation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,24 @@ async def validate_confirmation_and_redirect(request: web.Request):
180180

181181
except Exception as err: # pylint: disable=broad-except
182182
error_code = create_error_code(err)
183-
front_end_msg = (
183+
user_error_msg = (
184184
f"Sorry, we cannot confirm your {action}."
185185
"Please try again in a few moments. "
186186
f"If the problem persist please contact support attaching this code ({error_code})"
187187
)
188188

189189
_logger.exception(
190190
**create_troubleshotting_log_kwargs(
191-
front_end_msg,
192-
exception=err,
191+
user_error_msg,
192+
error=err,
193193
tip="Failed during email_confirmation",
194194
)
195195
)
196196

197197
raise create_redirect_to_page_response(
198198
request.app,
199199
page="error",
200-
message=front_end_msg,
200+
message=user_error_msg,
201201
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
202202
) from err
203203

services/web/server/src/simcore_service_webserver/login/handlers_registration.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -267,19 +267,26 @@ async def register(request: web.Request):
267267
)
268268
except Exception as err: # pylint: disable=broad-except
269269
error_code = create_error_code(err)
270+
user_error_msg = f"{MSG_CANT_SEND_MAIL} [{error_code}]"
271+
270272
_logger.exception(
271-
"Failed while sending confirmation email to %s, %s [%s]",
272-
f"{user=}",
273-
f"{_confirmation=}",
274-
f"{error_code}",
275-
extra={"error_code": error_code},
273+
**create_troubleshotting_log_kwargs(
274+
user_error_msg,
275+
error=err,
276+
error_context={
277+
"request": request,
278+
"registration": registration,
279+
"user_id": user.get("id"),
280+
"user": user,
281+
"confirmation": _confirmation,
282+
},
283+
tip="Failed while sending confirmation email",
284+
)
276285
)
277286

278287
await db.delete_confirmation_and_user(user, _confirmation)
279288

280-
raise web.HTTPServiceUnavailable(
281-
reason=f"{MSG_CANT_SEND_MAIL} [{error_code}]"
282-
) from err
289+
raise web.HTTPServiceUnavailable(reason=user_error_msg) from err
283290

284291
return flash_response(
285292
"You are registered successfully! To activate your account, please, "
@@ -401,18 +408,18 @@ async def register_phone(request: web.Request):
401408
except Exception as err: # pylint: disable=broad-except
402409
# Unhandled errors -> 503
403410
error_code = create_error_code(err)
404-
user_msg = f"Currently we cannot register phone numbers [{error_code}]"
411+
user_error_msg = f"Currently we cannot register phone numbers [{error_code}]"
405412

406413
_logger.exception(
407414
**create_troubleshotting_log_kwargs(
408-
user_msg,
409-
exception=err,
415+
user_error_msg,
416+
error=err,
410417
error_context={"request": request, "registration": registration},
411418
tip="Phone registration failed",
412419
)
413420
)
414421

415422
raise web.HTTPServiceUnavailable(
416-
reason=user_msg,
423+
reason=user_error_msg,
417424
content_type=MIMETYPE_APPLICATION_JSON,
418425
) from err

services/web/server/src/simcore_service_webserver/studies_dispatcher/_redirects_handlers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,20 @@ async def wrapper(request: web.Request) -> web.StreamResponse:
126126
except (ValidationError, web.HTTPServerError, Exception) as err:
127127
error_code = create_error_code(err)
128128

129-
front_end_msg = compose_support_error_msg(
129+
user_error_msg = compose_support_error_msg(
130130
msg=MSG_UNEXPECTED_ERROR.format(hint=""), error_code=error_code
131131
)
132132
_logger.exception(
133133
**create_troubleshotting_log_kwargs(
134-
front_end_msg,
135-
exception=err,
134+
user_error_msg,
135+
error=err,
136136
error_context={"request": request},
137137
tip="Unexpected failure while dispatching study",
138138
)
139139
)
140140
raise _create_redirect_response_to_error_page(
141141
request.app,
142-
message=front_end_msg,
142+
message=user_error_msg,
143143
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
144144
) from err
145145

0 commit comments

Comments
 (0)