wallet-core: truncate withdrawal errors

This commit is contained in:
Florian Dold 2023-06-06 17:25:17 +02:00
parent 698f356659
commit d8d214942c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 8 additions and 1 deletions

View File

@ -98,6 +98,7 @@ export interface DetailsMap {
};
[TalerErrorCode.WALLET_EXCHANGE_COIN_SIGNATURE_INVALID]: empty;
[TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE]: {
numErrors: number,
errorsPerCoin: Record<number, TalerErrorDetail>;
};
[TalerErrorCode.WALLET_CORE_NOT_AVAILABLE]: empty;

View File

@ -1426,6 +1426,8 @@ async function processWithdrawalGroupPendingReady(
let numKycRequired = 0;
let finishedForFirstTime = false;
const errorsPerCoin: Record<number, TalerErrorDetail> = {};
let numPlanchetErrors = 0;
const maxReportedErrors = 5;
const res = await ws.db
.mktx((x) => [x.coins, x.withdrawalGroups, x.planchets])
@ -1445,7 +1447,10 @@ async function processWithdrawalGroupPendingReady(
numKycRequired++;
}
if (x.lastError) {
errorsPerCoin[x.coinIdx] = x.lastError;
numPlanchetErrors++;
if (numPlanchetErrors < maxReportedErrors) {
errorsPerCoin[x.coinIdx] = x.lastError;
}
}
});
const oldTxState = computeWithdrawalTransactionStatus(wg);
@ -1507,6 +1512,7 @@ async function processWithdrawalGroupPendingReady(
throw TalerError.fromDetail(
TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE,
{
numErrors: numPlanchetErrors,
errorsPerCoin,
},
`withdrawal did not finish (${numFinished} / ${numTotalCoins} coins withdrawn)`,