diff options
author | Sebastian <sebasjm@gmail.com> | 2023-01-09 20:20:09 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-01-09 20:20:09 -0300 |
commit | 4a781bd0dd8828ce152f6ab2c3f1bbd6b5e826f7 (patch) | |
tree | 5c16976f99eb973ff62d78ed64107ca01df57b99 /packages/taler-wallet-webextension/src/popup/BalancePage.tsx | |
parent | 8a70edb2f8e235c3462127b0aa4e1b65aa1aee0b (diff) | |
download | wallet-core-4a781bd0dd8828ce152f6ab2c3f1bbd6b5e826f7.tar.xz |
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
Diffstat (limited to 'packages/taler-wallet-webextension/src/popup/BalancePage.tsx')
-rw-r--r-- | packages/taler-wallet-webextension/src/popup/BalancePage.tsx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx index 96f0f6dd9..87767d008 100644 --- a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx +++ b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx @@ -22,7 +22,11 @@ import { BalanceTable } from "../components/BalanceTable.js"; import { ErrorAlertView } from "../components/CurrentAlerts.js"; import { Loading } from "../components/Loading.js"; import { MultiActionButton } from "../components/MultiActionButton.js"; -import { alertFromError, ErrorAlert } from "../context/alert.js"; +import { + alertFromError, + ErrorAlert, + useAlertContext, +} from "../context/alert.js"; import { useBackendContext } from "../context/backend.js"; import { useTranslationContext } from "../context/translation.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; @@ -75,6 +79,7 @@ function useComponentState({ }: Props): State { const api = useBackendContext(); const { i18n } = useTranslationContext(); + const { pushAlertOnError } = useAlertContext(); const [addingAction, setAddingAction] = useState(false); const state = useAsyncAsHook(() => api.wallet.call(WalletApiOperation.GetBalances, {}), @@ -104,7 +109,7 @@ function useComponentState({ status: "action", error: undefined, cancel: { - onClick: async () => setAddingAction(false), + onClick: pushAlertOnError(async () => setAddingAction(false)), }, }; } @@ -113,10 +118,10 @@ function useComponentState({ error: undefined, balances: state.response.balances, addAction: { - onClick: async () => setAddingAction(true), + onClick: pushAlertOnError(async () => setAddingAction(true)), }, goToWalletManualWithdraw: { - onClick: goToWalletManualWithdraw, + onClick: pushAlertOnError(goToWalletManualWithdraw), }, goToWalletDeposit, goToWalletHistory, |