From 4a781bd0dd8828ce152f6ab2c3f1bbd6b5e826f7 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
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
---
 packages/taler-wallet-webextension/src/wallet/History.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/wallet/History.tsx')

diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx b/packages/taler-wallet-webextension/src/wallet/History.tsx
index 143d3adbb..1d51f835a 100644
--- a/packages/taler-wallet-webextension/src/wallet/History.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/History.tsx
@@ -23,7 +23,7 @@ import {
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { Fragment, h, VNode } from "preact";
 import { useEffect, useState } from "preact/hooks";
-import { AlertView } from "../components/CurrentAlerts.js";
+import { ErrorAlertView } from "../components/CurrentAlerts.js";
 import { Loading } from "../components/Loading.js";
 import {
   CenteredBoldText,
@@ -33,7 +33,7 @@ import {
 } from "../components/styled/index.js";
 import { Time } from "../components/Time.js";
 import { TransactionItem } from "../components/TransactionItem.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 { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
@@ -72,8 +72,8 @@ export function HistoryPage({
 
   if (state.hasError) {
     return (
-      <AlertView
-        alert={alertFromError(
+      <ErrorAlertView
+        error={alertFromError(
           i18n.str`Could not load the list of transactions`,
           state,
         )}
@@ -112,6 +112,7 @@ export function HistoryView({
 }): VNode {
   const { i18n } = useTranslationContext();
   const currencies = balances.map((b) => b.available.split(":")[0]);
+  const { pushAlertOnError } = useAlertContext();
 
   const defaultCurrencyIndex = currencies.findIndex(
     (c) => c === defaultCurrency,
@@ -145,7 +146,7 @@ export function HistoryView({
     return (
       <NoBalanceHelp
         goToWalletManualWithdraw={{
-          onClick: goToWalletManualWithdraw,
+          onClick: pushAlertOnError(goToWalletManualWithdraw),
         }}
       />
     );
-- 
cgit v1.2.3

