summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli/src/index.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-03-22 21:16:38 +0100
committerFlorian Dold <florian@dold.me>2022-03-22 21:16:38 +0100
commit5d23eb36354d07508a015531f298b3e261bbafce (patch)
treefae0d2599c94d88c9264bb63a301adb1706824c1 /packages/taler-wallet-cli/src/index.ts
parentf8d12f7b0d4af1b1769b89e80c87f9c169678564 (diff)
downloadwallet-core-5d23eb36354d07508a015531f298b3e261bbafce.tar.gz
wallet-core-5d23eb36354d07508a015531f298b3e261bbafce.tar.bz2
wallet-core-5d23eb36354d07508a015531f298b3e261bbafce.zip
wallet: improve error handling and error codes
Diffstat (limited to 'packages/taler-wallet-cli/src/index.ts')
-rw-r--r--packages/taler-wallet-cli/src/index.ts21
1 files changed, 7 insertions, 14 deletions
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<T>(
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");