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:
rin.kagamine committed 2026-06-04 21:28:09 -04:00
1 parent 71e4210386
commit abc3b7b191
1 file changed
+6 -1
+6 -1
View File
@@ -361,9 +361,14 @@ class Tools:
# Error info # Error info
if is_failed: if is_failed:
# Show exception if present, otherwise show status failure # Priority: exception string > error_information.error_message > generic status
if exception: if exception:
err_short = exception[:80] + "…" if len(exception) > 80 else exception err_short = exception[:80] + "…" if len(exception) > 80 else exception
else:
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: else:
err_short = "status: failure" err_short = "status: failure"
base += f"\n └─ {err_short}" base += f"\n └─ {err_short}"