Skip to content

Commit c5f6b69

Browse files
committed
fix: propogate error_message to avoid silently dropping it
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
1 parent 22d8203 commit c5f6b69

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

openfeature/hook/logging_hook.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def error(
5959
self, hook_context: HookContext, exception: Exception, hints: HookHints
6060
) -> None:
6161
args = self._build_args(hook_context, "error")
62-
args["error_code"] = (
63-
exception.error_code
64-
if isinstance(exception, OpenFeatureError)
65-
else ErrorCode.GENERAL
66-
)
67-
args["error_message"] = str(exception)
62+
if isinstance(exception, OpenFeatureError):
63+
args["error_code"] = exception.error_code
64+
args["error_message"] = exception.error_message
65+
else:
66+
args["error_code"] = ErrorCode.GENERAL
67+
args["error_message"] = str(exception)
6868
self.logger.error("Flag evaluation %s", args)

tests/hook/test_logging_hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_error_extracts_error_code_from_open_feature_error(hook_context):
126126
"domain": "my-domain",
127127
"provider_name": "my-provider",
128128
"error_code": ErrorCode.FLAG_NOT_FOUND,
129-
"error_message": str(exception),
129+
"error_message": "flag not found",
130130
},
131131
)
132132

0 commit comments

Comments
 (0)