diff options
author | Sebastian <sebasjm@gmail.com> | 2023-01-09 08:38:48 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-01-09 08:38:48 -0300 |
commit | 9b04d8bf3581d162cbd631892ca115df811c46f8 (patch) | |
tree | 42b7da7cc3a3f8186823a7571aa221dc8e9aa7a5 /packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts | |
parent | 14f3d1e06dda003d457f2b3531e197011a284244 (diff) | |
download | wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.xz |
fix #7152
Diffstat (limited to 'packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts index 1b2929317..978ea90e1 100644 --- a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts +++ b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts @@ -16,6 +16,7 @@ import { TalerErrorDetail } from "@gnu-taler/taler-util"; import { TalerError } from "@gnu-taler/taler-wallet-core"; import { useEffect, useMemo, useState } from "preact/hooks"; +import { WalletError } from "../wxApi.js"; export interface HookOk<T> { hasError: false; @@ -26,13 +27,14 @@ export type HookError = HookGenericError | HookOperationalError; export interface HookGenericError { hasError: true; - operational: false; + type: "error"; message: string; } export interface HookOperationalError { hasError: true; - operational: true; + type: "taler"; + message: string; details: TalerErrorDetail; } @@ -68,13 +70,21 @@ export function useAsyncAsHook<T>( if (e instanceof TalerError) { setHookResponse({ hasError: true, - operational: true, + type: "taler", + message: e.message, details: e.errorDetail, }); + } else if (e instanceof WalletError) { + setHookResponse({ + hasError: true, + type: "taler", + message: e.message, + details: e.errorDetail.errorDetail, + }); } else if (e instanceof Error) { setHookResponse({ hasError: true, - operational: false, + type: "error", message: e.message, }); } |