add 'when' to error-detail and remove error as normal response when doing backup
This commit is contained in:
parent
efb5bf9de4
commit
8a70edb2f8
@ -249,6 +249,7 @@ export interface ConfirmPayResultPending {
|
|||||||
export const codecForTalerErrorDetail = (): Codec<TalerErrorDetail> =>
|
export const codecForTalerErrorDetail = (): Codec<TalerErrorDetail> =>
|
||||||
buildCodecForObject<TalerErrorDetail>()
|
buildCodecForObject<TalerErrorDetail>()
|
||||||
.property("code", codecForNumber())
|
.property("code", codecForNumber())
|
||||||
|
.property("when", codecForString())
|
||||||
.property("hint", codecOptional(codecForString()))
|
.property("hint", codecOptional(codecForString()))
|
||||||
.build("TalerErrorDetail");
|
.build("TalerErrorDetail");
|
||||||
|
|
||||||
@ -537,6 +538,7 @@ export interface WalletDiagnostics {
|
|||||||
|
|
||||||
export interface TalerErrorDetail {
|
export interface TalerErrorDetail {
|
||||||
code: TalerErrorCode;
|
code: TalerErrorCode;
|
||||||
|
when: string;
|
||||||
hint?: string;
|
hint?: string;
|
||||||
[x: string]: unknown;
|
[x: string]: unknown;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ export class MyCryptoWorker implements CryptoWorker {
|
|||||||
type: "error",
|
type: "error",
|
||||||
error: {
|
error: {
|
||||||
code: 42,
|
code: 42,
|
||||||
|
when: "now",
|
||||||
hint: "bla",
|
hint: "bla",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -103,7 +103,8 @@ export function makeErrorDetail<C extends TalerErrorCode>(
|
|||||||
if (!hint && !(detail as any).hint) {
|
if (!hint && !(detail as any).hint) {
|
||||||
hint = getDefaultHint(code);
|
hint = getDefaultHint(code);
|
||||||
}
|
}
|
||||||
return { code, hint, ...detail };
|
const when = new Date().toISOString();
|
||||||
|
return { code, when, hint, ...detail };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makePendingOperationFailedError(
|
export function makePendingOperationFailedError(
|
||||||
@ -160,7 +161,8 @@ export class TalerError<T = any> extends Error {
|
|||||||
if (!hint) {
|
if (!hint) {
|
||||||
hint = getDefaultHint(code);
|
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 {
|
static fromUncheckedDetail(d: TalerErrorDetail): TalerError {
|
||||||
|
@ -627,8 +627,7 @@ export const codecForAddBackupProviderRequest =
|
|||||||
|
|
||||||
export type AddBackupProviderResponse =
|
export type AddBackupProviderResponse =
|
||||||
| AddBackupProviderOk
|
| AddBackupProviderOk
|
||||||
| AddBackupProviderPaymentRequired
|
| AddBackupProviderPaymentRequired;
|
||||||
| AddBackupProviderError;
|
|
||||||
|
|
||||||
interface AddBackupProviderOk {
|
interface AddBackupProviderOk {
|
||||||
status: "ok";
|
status: "ok";
|
||||||
@ -637,10 +636,6 @@ interface AddBackupProviderPaymentRequired {
|
|||||||
status: "payment-required";
|
status: "payment-required";
|
||||||
talerUri?: string;
|
talerUri?: string;
|
||||||
}
|
}
|
||||||
interface AddBackupProviderError {
|
|
||||||
status: "error";
|
|
||||||
error: TalerErrorDetail;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const codecForAddBackupProviderOk = (): Codec<AddBackupProviderOk> =>
|
export const codecForAddBackupProviderOk = (): Codec<AddBackupProviderOk> =>
|
||||||
buildCodecForObject<AddBackupProviderOk>()
|
buildCodecForObject<AddBackupProviderOk>()
|
||||||
@ -654,13 +649,6 @@ export const codecForAddBackupProviderPaymenrRequired =
|
|||||||
.property("talerUri", codecOptional(codecForString()))
|
.property("talerUri", codecOptional(codecForString()))
|
||||||
.build("AddBackupProviderPaymentRequired");
|
.build("AddBackupProviderPaymentRequired");
|
||||||
|
|
||||||
export const codecForAddBackupProviderError =
|
|
||||||
(): Codec<AddBackupProviderError> =>
|
|
||||||
buildCodecForObject<AddBackupProviderError>()
|
|
||||||
.property("status", codecForConstString("error"))
|
|
||||||
.property("error", codecForTalerErrorDetail())
|
|
||||||
.build("AddBackupProviderError");
|
|
||||||
|
|
||||||
export const codecForAddBackupProviderResponse =
|
export const codecForAddBackupProviderResponse =
|
||||||
(): Codec<AddBackupProviderResponse> =>
|
(): Codec<AddBackupProviderResponse> =>
|
||||||
buildCodecForUnion<AddBackupProviderResponse>()
|
buildCodecForUnion<AddBackupProviderResponse>()
|
||||||
@ -670,7 +658,6 @@ export const codecForAddBackupProviderResponse =
|
|||||||
"payment-required",
|
"payment-required",
|
||||||
codecForAddBackupProviderPaymenrRequired(),
|
codecForAddBackupProviderPaymenrRequired(),
|
||||||
)
|
)
|
||||||
.alternative("error", codecForAddBackupProviderError())
|
|
||||||
.build("AddBackupProviderResponse");
|
.build("AddBackupProviderResponse");
|
||||||
|
|
||||||
export async function addBackupProvider(
|
export async function addBackupProvider(
|
||||||
@ -745,10 +732,10 @@ async function runFirstBackupCycleForProvider(
|
|||||||
const resp = await runBackupCycleForProvider(ws, args);
|
const resp = await runBackupCycleForProvider(ws, args);
|
||||||
switch (resp.type) {
|
switch (resp.type) {
|
||||||
case OperationAttemptResultType.Error:
|
case OperationAttemptResultType.Error:
|
||||||
return {
|
throw TalerError.fromDetail(
|
||||||
status: "error",
|
TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
||||||
error: resp.errorDetail,
|
resp.errorDetail,
|
||||||
};
|
);
|
||||||
case OperationAttemptResultType.Finished:
|
case OperationAttemptResultType.Finished:
|
||||||
return {
|
return {
|
||||||
status: "ok",
|
status: "ok",
|
||||||
|
@ -55,6 +55,7 @@ import {
|
|||||||
ExchangeHandle,
|
ExchangeHandle,
|
||||||
canonicalizeBaseUrl,
|
canonicalizeBaseUrl,
|
||||||
parsePaytoUri,
|
parsePaytoUri,
|
||||||
|
TalerErrorCode,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
AllowedAuditorInfo,
|
AllowedAuditorInfo,
|
||||||
@ -66,6 +67,7 @@ import { GetReadOnlyAccess } from "../util/query.js";
|
|||||||
import { InternalWalletState } from "../internal-wallet-state.js";
|
import { InternalWalletState } from "../internal-wallet-state.js";
|
||||||
import { getExchangeDetails } from "./exchanges.js";
|
import { getExchangeDetails } from "./exchanges.js";
|
||||||
import { checkLogicInvariant } from "../util/invariants.js";
|
import { checkLogicInvariant } from "../util/invariants.js";
|
||||||
|
import { TalerError } from "../errors.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger.
|
* Logger.
|
||||||
|
@ -1824,6 +1824,7 @@ export async function processPurchase(
|
|||||||
errorDetail: {
|
errorDetail: {
|
||||||
// FIXME: allocate more specific error code
|
// FIXME: allocate more specific error code
|
||||||
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
||||||
|
when: new Date().toISOString(),
|
||||||
hint: `trying to pay for purchase that is not in the database`,
|
hint: `trying to pay for purchase that is not in the database`,
|
||||||
proposalId: proposalId,
|
proposalId: proposalId,
|
||||||
},
|
},
|
||||||
@ -1874,6 +1875,7 @@ export async function processPurchasePay(
|
|||||||
errorDetail: {
|
errorDetail: {
|
||||||
// FIXME: allocate more specific error code
|
// FIXME: allocate more specific error code
|
||||||
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
||||||
|
when: new Date().toISOString(),
|
||||||
hint: `trying to pay for purchase that is not in the database`,
|
hint: `trying to pay for purchase that is not in the database`,
|
||||||
proposalId: proposalId,
|
proposalId: proposalId,
|
||||||
},
|
},
|
||||||
@ -1996,6 +1998,7 @@ export async function processPurchasePay(
|
|||||||
|
|
||||||
await scheduleRetry(ws, RetryTags.forPay(purchase), {
|
await scheduleRetry(ws, RetryTags.forPay(purchase), {
|
||||||
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
||||||
|
when: new Date().toISOString(),
|
||||||
message: "unexpected exception",
|
message: "unexpected exception",
|
||||||
hint: "unexpected exception",
|
hint: "unexpected exception",
|
||||||
details: {
|
details: {
|
||||||
|
Loading…
Reference in New Issue
Block a user