From 2e6f3b356971f3a56ff78db0ea6fa75ce0ab85b2 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 31 May 2022 15:08:31 +0200 Subject: -error reporting, code formatting --- packages/taler-wallet-core/src/errors.ts | 14 +++++++++++++- packages/taler-wallet-core/src/wallet.ts | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'packages/taler-wallet-core') diff --git a/packages/taler-wallet-core/src/errors.ts b/packages/taler-wallet-core/src/errors.ts index eda5444bf..56017cc00 100644 --- a/packages/taler-wallet-core/src/errors.ts +++ b/packages/taler-wallet-core/src/errors.ts @@ -94,6 +94,11 @@ export function makePendingOperationFailedError( }); } +export function summarizeTalerErrorDetail(ed: TalerErrorDetail): string { + const errName = TalerErrorCode[ed.code] ?? ""; + return `Error (${ed.code}/${errName})`; +} + export class TalerError extends Error { errorDetail: TalerErrorDetail & T; private constructor(d: TalerErrorDetail & T) { @@ -107,7 +112,14 @@ export class TalerError extends Error { detail: ErrBody, hint?: string, ): TalerError { - // FIXME: include default hint? + if (!hint) { + const errName = TalerErrorCode[code]; + if (errName) { + hint = `Error (${errName})`; + } else { + hint = `Error ()`; + } + } return new TalerError({ code, hint, ...detail }); } diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 689e45f3c..a0eaca2e9 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -296,7 +296,7 @@ export async function runPending( } catch (e) { if (e instanceof TalerError) { console.error( - "Operation failed:", + "Pending operation failed:", JSON.stringify(e.errorDetail, undefined, 2), ); } else { -- cgit v1.2.3