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/wxBackend.ts | |
parent | 14f3d1e06dda003d457f2b3531e197011a284244 (diff) | |
download | wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.xz |
fix #7152
Diffstat (limited to 'packages/taler-wallet-webextension/src/wxBackend.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/wxBackend.ts | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts index b75e92004..c7b964c28 100644 --- a/packages/taler-wallet-webextension/src/wxBackend.ts +++ b/packages/taler-wallet-webextension/src/wxBackend.ts @@ -46,9 +46,7 @@ import { WalletStoresV1, } from "@gnu-taler/taler-wallet-core"; import { BrowserHttpLib } from "./browserHttpLib.js"; -import { - platform, -} from "./platform/background.js"; +import { platform } from "./platform/background.js"; import { MessageFromBackend, MessageFromFrontend, @@ -199,13 +197,22 @@ async function dispatch<Op extends WalletOperations | BackgroundOperations>( ), }; } - const result = await handler(req.payload); - return { - type: "response", - id: req.id, - operation: String(req.operation), - result, - }; + try { + const result = await handler(req.payload); + return { + type: "response", + id: req.id, + operation: String(req.operation), + result, + }; + } catch (er) { + return { + type: "error", + id: req.id, + error: getErrorDetailFromException(er), + operation: String(req.operation), + }; + } } if (req.channel === "wallet") { @@ -232,7 +239,9 @@ async function dispatch<Op extends WalletOperations | BackgroundOperations>( id: anyReq.id, operation: String(anyReq.operation), error: getErrorDetailFromException( - Error(`unknown channel ${anyReq.channel}`), + Error( + `unknown channel ${anyReq.channel}, should be "background" or "wallet"`, + ), ), }; } |