|
9 | 9 | from pydantic import BaseModel, Field, PositiveInt, SecretStr, validator |
10 | 10 | from servicelib.aiohttp import status |
11 | 11 | from servicelib.aiohttp.requests_validation import parse_request_body_as |
| 12 | +from servicelib.logging_errors import create_troubleshotting_log_kwargs |
12 | 13 | from servicelib.mimetype_constants import MIMETYPE_APPLICATION_JSON |
13 | 14 | from simcore_postgres_database.models.users import UserStatus |
14 | 15 |
|
|
58 | 59 | ) |
59 | 60 | from .utils_email import get_template_path, send_email_from_template |
60 | 61 |
|
61 | | -log = logging.getLogger(__name__) |
| 62 | +_logger = logging.getLogger(__name__) |
62 | 63 |
|
63 | 64 |
|
64 | 65 | routes = RouteTableDef() |
@@ -266,7 +267,7 @@ async def register(request: web.Request): |
266 | 267 | ) |
267 | 268 | except Exception as err: # pylint: disable=broad-except |
268 | 269 | error_code = create_error_code(err) |
269 | | - log.exception( |
| 270 | + _logger.exception( |
270 | 271 | "Failed while sending confirmation email to %s, %s [%s]", |
271 | 272 | f"{user=}", |
272 | 273 | f"{_confirmation=}", |
@@ -400,13 +401,18 @@ async def register_phone(request: web.Request): |
400 | 401 | except Exception as err: # pylint: disable=broad-except |
401 | 402 | # Unhandled errors -> 503 |
402 | 403 | error_code = create_error_code(err) |
403 | | - log.exception( |
404 | | - "Phone registration failed [%s]", |
405 | | - f"{error_code}", |
406 | | - extra={"error_code": error_code}, |
| 404 | + user_msg = f"Currently we cannot register phone numbers [{error_code}]" |
| 405 | + |
| 406 | + _logger.exception( |
| 407 | + **create_troubleshotting_log_kwargs( |
| 408 | + user_msg, |
| 409 | + exception=err, |
| 410 | + error_context={"request": request, "registration": registration}, |
| 411 | + tip="Phone registration failed", |
| 412 | + ) |
407 | 413 | ) |
408 | 414 |
|
409 | 415 | raise web.HTTPServiceUnavailable( |
410 | | - reason=f"Currently we cannot register phone numbers ({error_code})", |
| 416 | + reason=user_msg, |
411 | 417 | content_type=MIMETYPE_APPLICATION_JSON, |
412 | 418 | ) from err |
0 commit comments