Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Commit

Permalink
feat: Improve CLI error message format (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Mar 10, 2022
1 parent ed8a022 commit 94d9ba4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions changes/209.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve CLI error formatting to use more sensible "message" and "data" fields
6 changes: 3 additions & 3 deletions src/ai/backend/client/cli/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,17 @@ def format_error(exc: Exception):
yield f"\n- {per_field_errors}"
else:
if exc.data['type'].endswith('/graphql-error'):
yield "\n\u279c Error details:\n"
yield "\n\u279c Message:\n"
yield from (f"{err_item['message']}\n"
for err_item in exc.data.get('data', []))
else:
other_details = exc.data.get('msg', None)
if other_details:
yield '\n\u279c Error details: '
yield '\n\u279c Message: '
yield str(other_details)
other_data = exc.data.get('data', None)
if other_data:
yield '\n\u279c Error details: '
yield '\n\u279c Data: '
yield repr(other_data)
agent_details = exc.data.get('agent-details', None)
if agent_details is not None:
Expand Down

0 comments on commit 94d9ba4

Please sign in to comment.