handleAsyncBulkTransactionFailure handles failures in asynchronous processing and builds a detailed error message including rollback status
(ctx context.Context, err error, batchID string, isAtomic bool, isInflight bool)
| 2486 | // handleAsyncBulkTransactionFailure handles failures in asynchronous processing |
| 2487 | // and builds a detailed error message including rollback status |
| 2488 | func (l *LedgerForge) handleAsyncBulkTransactionFailure(ctx context.Context, err error, batchID string, isAtomic bool, isInflight bool) { |
| 2489 | logrus.WithError(err).WithField("batch_id", batchID).Error("async bulk transaction error") |
| 2490 | |
| 2491 | var errorMessage string |
| 2492 | |
| 2493 | if isAtomic { |
| 2494 | action, rollbackErr := l.rollbackBatchTransactions(ctx, batchID, isInflight) |
| 2495 | |
| 2496 | if rollbackErr != nil { |
| 2497 | errorMessage = fmt.Sprintf("%s. Failed to roll back all transactions: %s", err.Error(), rollbackErr.Error()) |
| 2498 | logrus.WithError(rollbackErr).WithField("batch_id", batchID).Error("failed to roll back batch") |
| 2499 | } else { |
| 2500 | errorMessage = fmt.Sprintf("%s. All transactions in this batch have been %s.", err.Error(), action) |
| 2501 | logrus.WithFields(logrus.Fields{ |
| 2502 | "batch_id": batchID, |
| 2503 | "action": action, |
| 2504 | }).Info("successfully rolled back async batch") |
| 2505 | } |
| 2506 | } else { |
| 2507 | // If not atomic, just include the original error and note about no rollback |
| 2508 | errorMessage = fmt.Sprintf("%s. Previous transactions were not rolled back.", err.Error()) |
| 2509 | } |
| 2510 | |
| 2511 | // Send webhook with the complete error message including rollback status |
| 2512 | l.sendBulkTransactionWebhook(batchID, "failed", errorMessage, 0) // 0 count for failed batch |
| 2513 | } |
| 2514 | |
| 2515 | // CreateBulkTransactions handles the creation of multiple transactions in a batch. |
| 2516 | // If atomic is true: Any failure will cause all transactions to be rolled back (or voided if inflight). |
no test coverage detected