summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wxApi.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/wxApi.ts')
-rw-r--r--packages/taler-wallet-webextension/src/wxApi.ts26
1 files changed, 11 insertions, 15 deletions
diff --git a/packages/taler-wallet-webextension/src/wxApi.ts b/packages/taler-wallet-webextension/src/wxApi.ts
index a41372e37..0393661ac 100644
--- a/packages/taler-wallet-webextension/src/wxApi.ts
+++ b/packages/taler-wallet-webextension/src/wxApi.ts
@@ -93,22 +93,12 @@ export interface BackgroundApiClient {
): Promise<BackgroundOperations[Op]["response"]>;
}
-export class WalletError extends Error {
- public errorDetail: TalerError;
-
- constructor(op: string, e: TalerError) {
- super(`Wallet operation "${op}" failed: ${e.message}`);
- this.errorDetail = e;
- // Object.setPrototypeOf(this, WalletError.prototype);
- }
-}
export class BackgroundError extends Error {
public errorDetail: TalerErrorDetail;
- constructor(op: string, e: TalerErrorDetail) {
- super(`Background operation "${op}" failed: ${e.message}`);
+ constructor(title: string, e: TalerErrorDetail) {
+ super(title);
this.errorDetail = e;
- // Object.setPrototypeOf(this, BackgroundError.prototype);
}
}
@@ -135,13 +125,17 @@ class BackgroundApiClientImpl implements BackgroundApiClient {
if (error instanceof Error) {
throw new BackgroundError(operation, {
code: TalerErrorCode.GENERIC_UNEXPECTED_REQUEST_ERROR,
+ when: new Date().toISOString(),
});
}
throw error;
}
logger.info("got response", response);
if (response.type === "error") {
- throw new BackgroundError(operation, response.error);
+ throw new BackgroundError(
+ `Background operation "${operation}" failed`,
+ response.error,
+ );
}
return response.result as any;
}
@@ -169,8 +163,10 @@ class WalletApiClientImpl implements WalletCoreApiClient {
}
logger.info("got response", response);
if (response.type === "error") {
- const error = TalerError.fromUncheckedDetail(response.error);
- throw new WalletError(operation, error);
+ throw new BackgroundError(
+ `Wallet operation "${operation}" failed`,
+ response.error,
+ );
}
return response.result as any;
}