|
13 | 13 | from aiohttp.web_request import Request |
14 | 14 | from aiohttp.web_response import StreamResponse |
15 | 15 | from models_library.error_codes import create_error_code |
16 | | -from models_library.errors_classes import OsparcErrorMixin |
17 | 16 | from models_library.utils.json_serialization import json_dumps |
18 | 17 |
|
19 | | -from ..logging_errors import create_troubleshotting_log_message, get_log_record_extra |
| 18 | +from ..logging_errors import create_troubleshotting_log_kwargs |
20 | 19 | from ..mimetype_constants import MIMETYPE_APPLICATION_JSON |
21 | 20 | from ..utils import is_production_environ |
22 | 21 | from .rest_models import ErrorItemType, ErrorType, LogMessageType |
@@ -59,31 +58,22 @@ def _process_and_raise_unexpected_error(request: web.BaseRequest, err: Exception |
59 | 58 | "request.method": f"{request.method}", |
60 | 59 | "request.path": f"{request.path}", |
61 | 60 | } |
62 | | - if isinstance(err, OsparcErrorMixin): |
63 | | - error_context.update(err.error_context()) |
64 | 61 |
|
65 | 62 | frontend_msg = _FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC.format( |
66 | 63 | error_code=error_code |
67 | 64 | ) |
68 | | - log_msg = create_troubleshotting_log_message( |
69 | | - message_to_user=frontend_msg, |
70 | | - exception=err, |
71 | | - error_code=error_code, |
72 | | - error_context=error_context, |
73 | | - ) |
74 | | - |
75 | 65 | http_error = create_http_error( |
76 | 66 | err, |
77 | 67 | frontend_msg, |
78 | 68 | web.HTTPInternalServerError, |
79 | 69 | skip_internal_error_details=_is_prod, |
80 | 70 | ) |
81 | 71 | _logger.exception( |
82 | | - log_msg, |
83 | | - extra=get_log_record_extra( |
84 | | - error_code=error_code, |
85 | | - user_id=error_context.get("user_id"), |
86 | | - ), |
| 72 | + **create_troubleshotting_log_kwargs( |
| 73 | + message_to_user=frontend_msg, |
| 74 | + exception=err, |
| 75 | + error_context=error_context, |
| 76 | + ) |
87 | 77 | ) |
88 | 78 | raise http_error |
89 | 79 |
|
|
0 commit comments