aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-util/src/wallet-types.ts2
-rw-r--r--packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts1
-rw-r--r--packages/taler-wallet-core/src/errors.ts6
-rw-r--r--packages/taler-wallet-core/src/operations/backup/index.ts23
-rw-r--r--packages/taler-wallet-core/src/operations/balance.ts2
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts3
6 files changed, 17 insertions, 20 deletions
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index 06edfe285..367d9c4c9 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -249,6 +249,7 @@ export interface ConfirmPayResultPending {
export const codecForTalerErrorDetail = (): Codec<TalerErrorDetail> =>
buildCodecForObject<TalerErrorDetail>()
.property("code", codecForNumber())
+ .property("when", codecForString())
.property("hint", codecOptional(codecForString()))
.build("TalerErrorDetail");
@@ -537,6 +538,7 @@ export interface WalletDiagnostics {
export interface TalerErrorDetail {
code: TalerErrorCode;
+ when: string;
hint?: string;
[x: string]: unknown;
}
diff --git a/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts b/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts
index df2e645a7..ca4a79d20 100644
--- a/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/crypto-dispatcher.test.ts
@@ -74,6 +74,7 @@ export class MyCryptoWorker implements CryptoWorker {
type: "error",
error: {
code: 42,
+ when: "now",
hint: "bla",
},
};
diff --git a/packages/taler-wallet-core/src/errors.ts b/packages/taler-wallet-core/src/errors.ts
index 37a31a8aa..308e9c7a8 100644
--- a/packages/taler-wallet-core/src/errors.ts
+++ b/packages/taler-wallet-core/src/errors.ts
@@ -103,7 +103,8 @@ export function makeErrorDetail<C extends TalerErrorCode>(
if (!hint && !(detail as any).hint) {
hint = getDefaultHint(code);
}
- return { code, hint, ...detail };
+ const when = new Date().toISOString();
+ return { code, when, hint, ...detail };
}
export function makePendingOperationFailedError(
@@ -160,7 +161,8 @@ export class TalerError<T = any> extends Error {
if (!hint) {
hint = getDefaultHint(code);
}
- return new TalerError<unknown>({ code, hint, ...detail });
+ const when = new Date().toISOString();
+ return new TalerError<unknown>({ code, when, hint, ...detail });
}
static fromUncheckedDetail(d: TalerErrorDetail): TalerError {
diff --git a/packages/taler-wallet-core/src/operations/backup/index.ts b/packages/taler-wallet-core/src/operations/backup/index.ts
index a44e8f55a..27d27da0d 100644
--- a/packages/taler-wallet-core/src/operations/backup/index.ts
+++ b/packages/taler-wallet-core/src/operations/backup/index.ts
@@ -627,8 +627,7 @@ export const codecForAddBackupProviderRequest =
export type AddBackupProviderResponse =
| AddBackupProviderOk
- | AddBackupProviderPaymentRequired
- | AddBackupProviderError;
+ | AddBackupProviderPaymentRequired;
interface AddBackupProviderOk {
status: "ok";
@@ -637,10 +636,6 @@ interface AddBackupProviderPaymentRequired {
status: "payment-required";
talerUri?: string;
}
-interface AddBackupProviderError {
- status: "error";
- error: TalerErrorDetail;
-}
export const codecForAddBackupProviderOk = (): Codec<AddBackupProviderOk> =>
buildCodecForObject<AddBackupProviderOk>()
@@ -654,13 +649,6 @@ export const codecForAddBackupProviderPaymenrRequired =
.property("talerUri", codecOptional(codecForString()))
.build("AddBackupProviderPaymentRequired");
-export const codecForAddBackupProviderError =
- (): Codec<AddBackupProviderError> =>
- buildCodecForObject<AddBackupProviderError>()
- .property("status", codecForConstString("error"))
- .property("error", codecForTalerErrorDetail())
- .build("AddBackupProviderError");
-
export const codecForAddBackupProviderResponse =
(): Codec<AddBackupProviderResponse> =>
buildCodecForUnion<AddBackupProviderResponse>()
@@ -670,7 +658,6 @@ export const codecForAddBackupProviderResponse =
"payment-required",
codecForAddBackupProviderPaymenrRequired(),
)
- .alternative("error", codecForAddBackupProviderError())
.build("AddBackupProviderResponse");
export async function addBackupProvider(
@@ -745,10 +732,10 @@ async function runFirstBackupCycleForProvider(
const resp = await runBackupCycleForProvider(ws, args);
switch (resp.type) {
case OperationAttemptResultType.Error:
- return {
- status: "error",
- error: resp.errorDetail,
- };
+ throw TalerError.fromDetail(
+ TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
+ resp.errorDetail,
+ );
case OperationAttemptResultType.Finished:
return {
status: "ok",
diff --git a/packages/taler-wallet-core/src/operations/balance.ts b/packages/taler-wallet-core/src/operations/balance.ts
index 383aa5dc1..2c57f8af8 100644
--- a/packages/taler-wallet-core/src/operations/balance.ts
+++ b/packages/taler-wallet-core/src/operations/balance.ts
@@ -55,6 +55,7 @@ import {
ExchangeHandle,
canonicalizeBaseUrl,
parsePaytoUri,
+ TalerErrorCode,
} from "@gnu-taler/taler-util";
import {
AllowedAuditorInfo,
@@ -66,6 +67,7 @@ import { GetReadOnlyAccess } from "../util/query.js";
import { InternalWalletState } from "../internal-wallet-state.js";
import { getExchangeDetails } from "./exchanges.js";
import { checkLogicInvariant } from "../util/invariants.js";
+import { TalerError } from "../errors.js";
/**
* Logger.
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index 6026e0860..570a50c47 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -1824,6 +1824,7 @@ export async function processPurchase(
errorDetail: {
// FIXME: allocate more specific error code
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
+ when: new Date().toISOString(),
hint: `trying to pay for purchase that is not in the database`,
proposalId: proposalId,
},
@@ -1874,6 +1875,7 @@ export async function processPurchasePay(
errorDetail: {
// FIXME: allocate more specific error code
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
+ when: new Date().toISOString(),
hint: `trying to pay for purchase that is not in the database`,
proposalId: proposalId,
},
@@ -1996,6 +1998,7 @@ export async function processPurchasePay(
await scheduleRetry(ws, RetryTags.forPay(purchase), {
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
+ when: new Date().toISOString(),
message: "unexpected exception",
hint: "unexpected exception",
details: {