Skip to content

Commit 04eba2f

Browse files
committed
adapts hander in api-server
1 parent e43c5b8 commit 04eba2f

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from models_library.rabbitmq_messages import LoggerRabbitMessage
99
from models_library.users import UserID
1010
from pydantic import NonNegativeInt
11+
from servicelib.logging_errors import create_troubleshotting_log_kwargs
1112
from servicelib.logging_utils import log_catch
1213
from servicelib.rabbitmq import RabbitMQClient
1314
from simcore_service_api_server.exceptions.backend_errors import BaseBackEndError
@@ -124,21 +125,23 @@ async def log_generator(self) -> AsyncIterable[str]:
124125
yield log.json() + _NEW_LINE
125126
except asyncio.TimeoutError:
126127
done = await self._project_done()
128+
127129
except BaseBackEndError as exc:
128130
_logger.info("%s", f"{exc}")
131+
129132
yield ErrorGet(errors=[f"{exc}"]).json() + _NEW_LINE
133+
130134
except Exception as exc: # pylint: disable=W0718
131135
error_code = create_error_code(exc)
136+
error_msg = MSG_INTERNAL_ERROR_USER_FRIENDLY_TEMPLATE + f" [{error_code}]"
137+
132138
_logger.exception(
133-
"Unexpected %s: %s",
134-
exc.__class__.__name__,
135-
f"{exc}",
136-
extra={"error_code": error_code},
139+
**create_troubleshotting_log_kwargs(
140+
error_msg,
141+
exception=exc,
142+
)
137143
)
138-
yield ErrorGet(
139-
errors=[
140-
MSG_INTERNAL_ERROR_USER_FRIENDLY_TEMPLATE + f" (OEC: {error_code})"
141-
]
142-
).json() + _NEW_LINE
144+
yield ErrorGet(errors=[error_msg]).json() + _NEW_LINE
145+
143146
finally:
144147
await self._log_distributor.deregister(self._job_id)

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
parse_request_body_as,
2222
parse_request_path_parameters_as,
2323
)
24+
from servicelib.logging_errors import create_troubleshotting_log_kwargs
2425
from servicelib.mimetype_constants import MIMETYPE_APPLICATION_JSON
2526
from simcore_postgres_database.errors import UniqueViolation
2627
from yarl import URL
@@ -179,17 +180,24 @@ async def validate_confirmation_and_redirect(request: web.Request):
179180

180181
except Exception as err: # pylint: disable=broad-except
181182
error_code = create_error_code(err)
183+
front_end_msg = (
184+
f"Sorry, we cannot confirm your {action}."
185+
"Please try again in a few moments. "
186+
f"If the problem persist please contact support attaching this code ({error_code})"
187+
)
188+
182189
_logger.exception(
183-
"Failed during email_confirmation [%s]",
184-
f"{error_code}",
185-
extra={"error_code": error_code},
190+
**create_troubleshotting_log_kwargs(
191+
front_end_msg,
192+
exception=err,
193+
tip="Failed during email_confirmation",
194+
)
186195
)
196+
187197
raise create_redirect_to_page_response(
188198
request.app,
189199
page="error",
190-
message=f"Sorry, we cannot confirm your {action}."
191-
"Please try again in a few moments. "
192-
"If the problem persist please contact support attaching this code ({error_code})",
200+
message=front_end_msg,
193201
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
194202
) from err
195203

0 commit comments

Comments
 (0)