From 4a781bd0dd8828ce152f6ab2c3f1bbd6b5e826f7 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Jan 2023 20:20:09 -0300 Subject: fix #7153: more error handling if handler do not trap error then fail at compile time, all safe handlers push alert on error errors are typed so they render good information --- .../src/components/ShowFullContractTermPopup.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx') diff --git a/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx b/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx index 9871611f2..3e1f1dbe4 100644 --- a/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx +++ b/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx @@ -24,14 +24,14 @@ import { useState } from "preact/hooks"; import { Loading } from "../components/Loading.js"; import { Modal } from "../components/Modal.js"; import { Time } from "../components/Time.js"; -import { alertFromError } from "../context/alert.js"; +import { alertFromError, useAlertContext } from "../context/alert.js"; import { useBackendContext } from "../context/backend.js"; import { useTranslationContext } from "../context/translation.js"; import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { ButtonHandler } from "../mui/handlers.js"; import { compose, StateViewMap } from "../utils/index.js"; import { Amount } from "./Amount.js"; -import { AlertView } from "./CurrentAlerts.js"; +import { ErrorAlertView } from "./CurrentAlerts.js"; import { Link } from "./styled/index.js"; const ContractTermsTable = styled.table` @@ -102,6 +102,7 @@ interface Props { function useComponentState({ proposalId }: Props): State { const api = useBackendContext(); const [show, setShow] = useState(false); + const { pushAlertOnError } = useAlertContext(); const hook = useAsyncAsHook(async () => { if (!show) return undefined; return await api.wallet.call(WalletApiOperation.GetContractTermsDetails, { @@ -110,10 +111,10 @@ function useComponentState({ proposalId }: Props): State { }, [show]); const hideHandler = { - onClick: async () => setShow(false), + onClick: pushAlertOnError(async () => setShow(false)), }; const showHandler = { - onClick: async () => setShow(true), + onClick: pushAlertOnError(async () => setShow(true)), }; if (!show) { return { @@ -161,8 +162,8 @@ export function ErrorView({ const { i18n } = useTranslationContext(); return ( -