diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-09-01 18:00:46 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-09-01 18:00:51 +0530 |
commit | 5056da6548d5880211abd3e1cdacd92134e40dab (patch) | |
tree | db7ede721ddd33c52dd862562b340f0782dabb22 /packages/taler-wallet-core/src/operations | |
parent | 5e7149f79eeb9988a7da45ecc8573c65e9680082 (diff) | |
download | wallet-core-5056da6548d5880211abd3e1cdacd92134e40dab.tar.xz |
test error handling
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
4 files changed, 23 insertions, 15 deletions
diff --git a/packages/taler-wallet-core/src/operations/errors.ts b/packages/taler-wallet-core/src/operations/errors.ts index 76f640344..6d9f44e03 100644 --- a/packages/taler-wallet-core/src/operations/errors.ts +++ b/packages/taler-wallet-core/src/operations/errors.ts @@ -66,8 +66,8 @@ export function makeErrorDetails( details: Record<string, unknown>, ): OperationErrorDetails { return { - talerErrorCode: ec, - talerErrorHint: `Error: ${TalerErrorCode[ec]}`, + code: ec, + hint: `Error: ${TalerErrorCode[ec]}`, details: details, message, }; diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index acad5e634..881961627 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -262,6 +262,7 @@ async function gatherWithdrawalPending( source: wsr.source, withdrawalGroupId: wsr.withdrawalGroupId, lastError: wsr.lastError, + retryInfo: wsr.retryInfo, }); }); } diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index d869ed770..3115b9506 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -165,6 +165,7 @@ export async function getTransactions( TransactionType.Withdrawal, wsr.withdrawalGroupId, ), + ...(wsr.lastError ? { error: wsr.lastError} : {}), }); } break; diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 270735fcb..3977ba121 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -59,6 +59,7 @@ import { import { readSuccessResponseJsonOrThrow } from "../util/http"; import { URL } from "../util/url"; import { TalerErrorCode } from "../TalerErrorCode"; +import { encodeCrock } from "../crypto/talerCrypto"; const logger = new Logger("withdraw.ts"); @@ -558,9 +559,6 @@ async function incrementWithdrawalRetry( if (!wsr) { return; } - if (!wsr.retryInfo) { - return; - } wsr.retryInfo.retryCounter++; updateRetryInfoTimeout(wsr.retryInfo); wsr.lastError = err; @@ -647,12 +645,13 @@ async function processWithdrawGroupImpl( let numFinished = 0; let finishedForFirstTime = false; + let errorsPerCoin: Record<number, OperationErrorDetails> = {}; await ws.db.runWithWriteTransaction( [Stores.coins, Stores.withdrawalGroups, Stores.reserves, Stores.planchets], async (tx) => { - const ws = await tx.get(Stores.withdrawalGroups, withdrawalGroupId); - if (!ws) { + const wg = await tx.get(Stores.withdrawalGroups, withdrawalGroupId); + if (!wg) { return; } @@ -662,22 +661,29 @@ async function processWithdrawGroupImpl( if (x.withdrawalDone) { numFinished++; } + if (x.lastError) { + errorsPerCoin[x.coinIdx] = x.lastError; + } }); - - if (ws.timestampFinish === undefined && numFinished == numTotalCoins) { + logger.trace(`now withdrawn ${numFinished} of ${numTotalCoins} coins`); + if (wg.timestampFinish === undefined && numFinished === numTotalCoins) { finishedForFirstTime = true; - ws.timestampFinish = getTimestampNow(); - ws.lastError = undefined; - ws.retryInfo = initRetryInfo(false); + wg.timestampFinish = getTimestampNow(); + wg.lastError = undefined; + wg.retryInfo = initRetryInfo(false); } - await tx.put(Stores.withdrawalGroups, ws); + + await tx.put(Stores.withdrawalGroups, wg); }, ); if (numFinished != numTotalCoins) { - // FIXME: aggregate individual problems into the big error message here. - throw Error( + throw OperationFailedError.fromCode( + TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE, `withdrawal did not finish (${numFinished} / ${numTotalCoins} coins withdrawn)`, + { + errorsPerCoin, + }, ); } |