Fix error handling in M2M schema for non-TigerBeetle exceptions

Handle both TB errors (with .code) and Python exceptions (without .code)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ruslan Bakiev
2026-01-04 00:36:05 +07:00
parent c849602be5
commit d0e532595b

View File

@@ -94,7 +94,8 @@ class CreateTransfer(graphene.Mutation):
if accounts_to_create:
account_errors = tigerbeetle_client.create_accounts(accounts_to_create)
if account_errors:
error_msg = f"Failed to create new accounts in TigerBeetle: {[e.code.name for e in account_errors]}"
error_details = [e.code.name if hasattr(e, 'code') else str(e) for e in account_errors]
error_msg = f"Failed to create new accounts in TigerBeetle: {error_details}"
logger.error(error_msg)
return CreateTransfer(success=False, message=error_msg)
@@ -111,7 +112,8 @@ class CreateTransfer(graphene.Mutation):
transfer_errors = tigerbeetle_client.create_transfers([transfer])
if transfer_errors:
error_msg = f"Transfer failed: {[e.code.name for e in transfer_errors]}"
error_details = [e.code.name if hasattr(e, 'code') else str(e) for e in transfer_errors]
error_msg = f"Transfer failed: {error_details}"
logger.error(error_msg)
return CreateTransfer(success=False, message=error_msg)