aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wxBackend.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/wxBackend.ts')
-rw-r--r--packages/taler-wallet-webextension/src/wxBackend.ts31
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"`,
+ ),
),
};
}