summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-09-01 15:52:13 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-09-01 15:52:13 +0530
commit5e7149f79eeb9988a7da45ecc8573c65e9680082 (patch)
tree892889ca8231d1a238de8264e0dbf96f349ff82f
parent5c0ee81e26698293b1d9fc028a9080afb1779b60 (diff)
downloadwallet-core-5e7149f79eeb9988a7da45ecc8573c65e9680082.tar.gz
wallet-core-5e7149f79eeb9988a7da45ecc8573c65e9680082.tar.bz2
wallet-core-5e7149f79eeb9988a7da45ecc8573c65e9680082.zip
fix exception thrown during logging, include stack trace
-rw-r--r--packages/taler-wallet-core/src/operations/errors.ts4
-rw-r--r--packages/taler-wallet-core/src/util/logging.ts25
-rw-r--r--packages/taler-wallet-core/src/wallet.ts1
3 files changed, 21 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/operations/errors.ts b/packages/taler-wallet-core/src/operations/errors.ts
index 198d3f8c5..76f640344 100644
--- a/packages/taler-wallet-core/src/operations/errors.ts
+++ b/packages/taler-wallet-core/src/operations/errors.ts
@@ -96,7 +96,9 @@ export async function guardOperationException<T>(
const opErr = makeErrorDetails(
TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
`unexpected exception (message: ${e.message})`,
- {},
+ {
+ stack: e.stack,
+ },
);
await onOpError(opErr);
throw new OperationFailedAndReportedError(opErr);
diff --git a/packages/taler-wallet-core/src/util/logging.ts b/packages/taler-wallet-core/src/util/logging.ts
index e4f3be2ff..230cb7053 100644
--- a/packages/taler-wallet-core/src/util/logging.ts
+++ b/packages/taler-wallet-core/src/util/logging.ts
@@ -22,18 +22,29 @@ const isNode =
typeof process !== "undefined" && process.release.name === "node";
function writeNodeLog(
- message: string,
+ message: any,
tag: string,
level: string,
args: any[],
): void {
- process.stderr.write(`${new Date().toISOString()} ${tag} ${level} `);
- process.stderr.write(message);
- if (args.length != 0) {
- process.stderr.write(" ");
- process.stderr.write(JSON.stringify(args, undefined, 2));
+ try {
+ process.stderr.write(`${new Date().toISOString()} ${tag} ${level} `);
+ process.stderr.write(`${message}`);
+ if (args.length != 0) {
+ process.stderr.write(" ");
+ process.stderr.write(JSON.stringify(args, undefined, 2));
+ }
+ process.stderr.write("\n");
+ } catch (e) {
+ // This can happen when we're trying to log something that doesn't want to be
+ // converted to a string.
+ process.stderr.write(`${new Date().toISOString()} (logger) FATAL `);
+ if (e instanceof Error) {
+ process.stderr.write("failed to write log: ");
+ process.stderr.write(e.message);
+ }
+ process.stderr.write("\n");
}
- process.stderr.write("\n");
}
/**
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 41b096bca..352cb29ef 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -919,7 +919,6 @@ export class Wallet {
/**
* Implementation of the "wallet-core" API.
*/
-
private async dispatchRequestInternal(
operation: string,
payload: unknown,