diff options
author | Florian Dold <florian@dold.me> | 2023-01-06 10:32:39 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-01-06 10:32:44 +0100 |
commit | 80639429a23c34bdfbb5f3853caf721b49fd6beb (patch) | |
tree | 5d3b06d13a599ef4b34a00a396fd8b843bd23d4d /packages/taler-wallet-core/src/operations/deposits.ts | |
parent | db1b824818b0f6c95499a96bd5cfa18306b15201 (diff) | |
download | wallet-core-80639429a23c34bdfbb5f3853caf721b49fd6beb.tar.xz |
wallet-core: test insufficient balance response, also use it for deposit groups
Diffstat (limited to 'packages/taler-wallet-core/src/operations/deposits.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/deposits.ts | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index 1cb051365..649621948 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -45,12 +45,14 @@ import { TrackDepositGroupResponse, TransactionType, URL, + TalerErrorCode, } from "@gnu-taler/taler-util"; import { DenominationRecord, DepositGroupRecord, OperationStatus, } from "../db.js"; +import { TalerError } from "../errors.js"; import { InternalWalletState } from "../internal-wallet-state.js"; import { readSuccessResponseJsonOrThrow } from "../util/http.js"; import { OperationAttemptResult } from "../util/retries.js"; @@ -269,7 +271,12 @@ export async function getFeeForDeposit( }); if (payCoinSel.type !== "success") { - throw Error("insufficient funds"); + throw TalerError.fromDetail( + TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE, + { + insufficientBalanceDetails: payCoinSel.insufficientBalanceDetails, + }, + ); } return await getTotalFeesForDepositAmount( @@ -356,7 +363,12 @@ export async function prepareDepositGroup( }); if (payCoinSel.type !== "success") { - throw Error("insufficient funds"); + throw TalerError.fromDetail( + TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE, + { + insufficientBalanceDetails: payCoinSel.insufficientBalanceDetails, + }, + ); } const totalDepositCost = await getTotalPaymentCost(ws, payCoinSel.coinSel); @@ -453,7 +465,12 @@ export async function createDepositGroup( }); if (payCoinSel.type !== "success") { - throw Error("insufficient funds"); + throw TalerError.fromDetail( + TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE, + { + insufficientBalanceDetails: payCoinSel.insufficientBalanceDetails, + }, + ); } const totalDepositCost = await getTotalPaymentCost(ws, payCoinSel.coinSel); |