summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-03-22 21:16:38 +0100
committerFlorian Dold <florian@dold.me>2022-03-22 21:16:38 +0100
commit5d23eb36354d07508a015531f298b3e261bbafce (patch)
treefae0d2599c94d88c9264bb63a301adb1706824c1 /packages/taler-wallet-webextension/src/cta
parentf8d12f7b0d4af1b1769b89e80c87f9c169678564 (diff)
downloadwallet-core-5d23eb36354d07508a015531f298b3e261bbafce.tar.gz
wallet-core-5d23eb36354d07508a015531f298b3e261bbafce.tar.bz2
wallet-core-5d23eb36354d07508a015531f298b3e261bbafce.zip
wallet: improve error handling and error codes
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
-rw-r--r--packages/taler-wallet-webextension/src/cta/Deposit.tsx14
-rw-r--r--packages/taler-wallet-webextension/src/cta/Pay.tsx4
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw.tsx13
3 files changed, 15 insertions, 16 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Deposit.tsx b/packages/taler-wallet-webextension/src/cta/Deposit.tsx
index ac6c1fd6d..933195a9e 100644
--- a/packages/taler-wallet-webextension/src/cta/Deposit.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Deposit.tsx
@@ -35,7 +35,7 @@ import {
PreparePayResultType,
Translate,
} from "@gnu-taler/taler-util";
-import { OperationFailedError } from "@gnu-taler/taler-wallet-core";
+import { TalerError } from "@gnu-taler/taler-wallet-core";
import { Fragment, h, VNode } from "preact";
import { useEffect, useState } from "preact/hooks";
import { ErrorTalerOperation } from "../components/ErrorTalerOperation";
@@ -64,9 +64,9 @@ export function DepositPage({ talerPayUri, goBack }: Props): VNode {
const [payResult, setPayResult] = useState<ConfirmPayResult | undefined>(
undefined,
);
- const [payErrMsg, setPayErrMsg] = useState<
- OperationFailedError | string | undefined
- >(undefined);
+ const [payErrMsg, setPayErrMsg] = useState<TalerError | string | undefined>(
+ undefined,
+ );
const balance = useAsyncAsHook(wxApi.getBalance, [
NotificationType.CoinWithdrawn,
@@ -97,7 +97,7 @@ export function DepositPage({ talerPayUri, goBack }: Props): VNode {
setPayStatus(p);
} catch (e) {
console.log("Got error while trying to pay", e);
- if (e instanceof OperationFailedError) {
+ if (e instanceof TalerError) {
setPayErrMsg(e);
}
if (e instanceof Error) {
@@ -117,7 +117,7 @@ export function DepositPage({ talerPayUri, goBack }: Props): VNode {
}
if (!payStatus) {
- if (payErrMsg instanceof OperationFailedError) {
+ if (payErrMsg instanceof TalerError) {
return (
<WalletAction>
<LogoHeader />
@@ -131,7 +131,7 @@ export function DepositPage({ talerPayUri, goBack }: Props): VNode {
Could not get the payment information for this order
</i18n.Translate>
}
- error={payErrMsg?.operationError}
+ error={payErrMsg?.errorDetail}
/>
</section>
</WalletAction>
diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx
index 2a0d1b46b..f6ae02f72 100644
--- a/packages/taler-wallet-webextension/src/cta/Pay.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx
@@ -36,7 +36,7 @@ import {
PreparePayResultType,
Product,
} from "@gnu-taler/taler-util";
-import { OperationFailedError } from "@gnu-taler/taler-wallet-core";
+import { TalerError } from "@gnu-taler/taler-wallet-core";
import { Fragment, h, VNode } from "preact";
import { useEffect, useState } from "preact/hooks";
import { ErrorMessage } from "../components/ErrorMessage";
@@ -93,7 +93,7 @@ export function PayPage({
undefined,
);
const [payErrMsg, setPayErrMsg] = useState<
- OperationFailedError | string | undefined
+ TalerError | string | undefined
>(undefined);
const hook = useAsyncAsHook(async () => {
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
index 66c83cf15..d58e2ec80 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
@@ -25,10 +25,8 @@ import {
AmountJson,
Amounts,
ExchangeListItem,
- Translate,
WithdrawUriInfoResponse,
} from "@gnu-taler/taler-util";
-import { OperationFailedError } from "@gnu-taler/taler-wallet-core";
import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
import { Loading } from "../components/Loading";
@@ -52,6 +50,7 @@ import {
import * as wxApi from "../wxApi";
import { TermsOfServiceSection } from "./TermsOfServiceSection";
import { useTranslationContext } from "../context/translation";
+import { TalerError } from "@gnu-taler/taler-wallet-core";
interface Props {
talerWithdrawUri?: string;
@@ -85,9 +84,9 @@ export function View({
reviewed,
}: ViewProps): VNode {
const { i18n } = useTranslationContext();
- const [withdrawError, setWithdrawError] = useState<
- OperationFailedError | undefined
- >(undefined);
+ const [withdrawError, setWithdrawError] = useState<TalerError | undefined>(
+ undefined,
+ );
const [confirmDisabled, setConfirmDisabled] = useState<boolean>(false);
const needsReview = terms.status === "changed" || terms.status === "new";
@@ -109,7 +108,7 @@ export function View({
setConfirmDisabled(true);
await onWithdraw();
} catch (e) {
- if (e instanceof OperationFailedError) {
+ if (e instanceof TalerError) {
setWithdrawError(e);
}
setConfirmDisabled(false);
@@ -130,7 +129,7 @@ export function View({
Could not finish the withdrawal operation
</i18n.Translate>
}
- error={withdrawError.operationError}
+ error={withdrawError.errorDetail}
/>
)}