From 5d23eb36354d07508a015531f298b3e261bbafce Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 22 Mar 2022 21:16:38 +0100 Subject: wallet: improve error handling and error codes --- packages/taler-wallet-cli/src/index.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'packages/taler-wallet-cli/src/index.ts') diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index f754ca915..e7b76fa9e 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -49,14 +49,13 @@ import { import { NodeHttpLib, getDefaultNodeWallet, - OperationFailedAndReportedError, - OperationFailedError, NodeThreadCryptoWorkerFactory, CryptoApi, walletCoreDebugFlags, WalletApiOperation, WalletCoreApiClient, Wallet, + getErrorDetailFromException, } from "@gnu-taler/taler-wallet-core"; import { lintExchangeDeployment } from "./lint.js"; import { runBench1 } from "./bench1.js"; @@ -206,18 +205,12 @@ async function withWallet( const ret = await f(w); return ret; } catch (e) { - if ( - e instanceof OperationFailedAndReportedError || - e instanceof OperationFailedError - ) { - console.error("Operation failed: " + e.message); - console.error( - "Error details:", - JSON.stringify(e.operationError, undefined, 2), - ); - } else { - console.error("caught unhandled exception (bug?):", e); - } + const ed = getErrorDetailFromException(e); + console.error("Operation failed: " + ed.message); + console.error( + "Error details:", + JSON.stringify(ed.operationError, undefined, 2), + ); process.exit(1); } finally { logger.info("operation with wallet finished, stopping"); -- cgit v1.2.3