aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r--packages/taler-wallet-core/src/errors.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/deposits.ts23
2 files changed, 24 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/errors.ts b/packages/taler-wallet-core/src/errors.ts
index 99a7fb535..68cd39b54 100644
--- a/packages/taler-wallet-core/src/errors.ts
+++ b/packages/taler-wallet-core/src/errors.ts
@@ -24,6 +24,7 @@
* Imports.
*/
import {
+ PayMerchantInsufficientBalanceDetails,
TalerErrorCode,
TalerErrorDetail,
TransactionType,
@@ -83,6 +84,9 @@ export interface DetailsMap {
[TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED]: {
// FIXME!
};
+ [TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE]: {
+ insufficientBalanceDetails: PayMerchantInsufficientBalanceDetails;
+ };
}
type ErrBody<Y> = Y extends keyof DetailsMap ? DetailsMap[Y] : never;
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);