Skip to content

Commit 07c8690

Browse files
committed
error-code
1 parent 1d18522 commit 07c8690

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pprint import pformat
33
from typing import Any, NotRequired, TypedDict
44

5-
from models_library.error_codes import ErrorCodeStr, create_error_code
5+
from models_library.error_codes import ErrorCodeStr
66
from models_library.errors_classes import OsparcErrorMixin
77

88
from .logging_utils import LogExtra, get_log_record_extra
@@ -48,7 +48,9 @@ class LogKwargs(TypedDict):
4848

4949
def create_troubleshotting_log_kwargs(
5050
user_error_msg: str,
51+
*,
5152
error: BaseException,
53+
error_code: ErrorCodeStr | None = None,
5254
error_context: dict[str, Any] | None = None,
5355
tip: str | None = None,
5456
) -> LogKwargs:
@@ -69,9 +71,6 @@ def create_troubleshotting_log_kwargs(
6971
)
7072
7173
"""
72-
# error-code
73-
error_code = create_error_code(error)
74-
7574
# error-context
7675
context = error_context or {}
7776
if isinstance(error, OsparcErrorMixin):

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ async def _http_error_handler(
3535
if add_exception_to_message:
3636
user_error_msg += f" {exception}"
3737

38+
error_code = create_error_code(exception)
3839
if add_oec_to_message:
39-
error_code = create_error_code(exception)
4040
user_error_msg += f" [{error_code}]"
4141

4242
_logger.exception(
4343
**create_troubleshotting_log_kwargs(
44-
user_error_msg, error=exception, tip="Unexpected error"
44+
user_error_msg,
45+
error=exception,
46+
error_code=error_code,
47+
tip="Unexpected error",
4548
)
4649
)
4750
return create_error_json_response(user_error_msg, status_code=status_code)

0 commit comments

Comments
 (0)