fix: surface error_information.error_message for failed requests without exception string
Entry 3 had metadata.status='failure' and no exception, but DID have error_information.error_message='No api key passed in.' Now we surface that actual error message instead of the generic 'status: failure'. Priority: exception > error_message > generic status.
This commit is contained in:
1 parent
71e4210386
commit
abc3b7b191
1 file changed
+7
-2
@@ -361,11 +361,16 @@ class Tools:
|
||||
|
||||
# Error info
|
||||
if is_failed:
|
||||
# Show exception if present, otherwise show status failure
|
||||
# Priority: exception string > error_information.error_message > generic status
|
||||
if exception:
|
||||
err_short = exception[:80] + "…" if len(exception) > 80 else exception
|
||||
else:
|
||||
err_short = "status: failure"
|
||||
err_info = metadata.get("error_information", {}) or {}
|
||||
err_msg = err_info.get("error_message", "")
|
||||
if err_msg:
|
||||
err_short = err_msg[:80] + "…" if len(err_msg) > 80 else err_msg
|
||||
else:
|
||||
err_short = "status: failure"
|
||||
base += f"\n └─ {err_short}"
|
||||
|
||||
lines.append(base)
|
||||
|
||||
Reference in new issue
Block a user