diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/context/alert.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/context/alert.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/taler-wallet-webextension/src/context/alert.ts b/packages/taler-wallet-webextension/src/context/alert.ts index 2b088abd3..b8918dc58 100644 --- a/packages/taler-wallet-webextension/src/context/alert.ts +++ b/packages/taler-wallet-webextension/src/context/alert.ts @@ -25,6 +25,7 @@ import { useContext, useState } from "preact/hooks"; import { HookError } from "../hooks/useAsyncAsHook.js"; import { SafeHandler, withSafe } from "../mui/handlers.js"; import { BackgroundError } from "../wxApi.js"; +import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; export type AlertType = "info" | "warning" | "error" | "success"; @@ -55,10 +56,7 @@ type Type = { * @deprecated use safely */ pushAlertOnError: <T>(h: (p: T) => Promise<void>) => SafeHandler<T>; - safely: <T>( - h: (p: T) => Promise<void>, - error: TranslatedString, - ) => SafeHandler<T>; + safely: <T>(name: string, h: (p: T) => Promise<void>) => SafeHandler<T>; }; const initial: Type = { @@ -113,10 +111,13 @@ export const AlertProvider = ({ children }: Props): VNode => { }); } + const { i18n } = useTranslationContext(); + function safely<T>( + name: string, handler: (p: T) => Promise<void>, - message: TranslatedString, ): SafeHandler<T> { + const message = i18n.str`Error was thrown trying to: "${name}"`; return withSafe(handler, (e) => { const a = alertFromError(message, e); pushAlert(a); |