fix exception thrown during logging, include stack trace
This commit is contained in:
parent
5c0ee81e26
commit
5e7149f79e
@ -96,7 +96,9 @@ export async function guardOperationException<T>(
|
|||||||
const opErr = makeErrorDetails(
|
const opErr = makeErrorDetails(
|
||||||
TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
|
||||||
`unexpected exception (message: ${e.message})`,
|
`unexpected exception (message: ${e.message})`,
|
||||||
{},
|
{
|
||||||
|
stack: e.stack,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
await onOpError(opErr);
|
await onOpError(opErr);
|
||||||
throw new OperationFailedAndReportedError(opErr);
|
throw new OperationFailedAndReportedError(opErr);
|
||||||
|
@ -22,18 +22,29 @@ const isNode =
|
|||||||
typeof process !== "undefined" && process.release.name === "node";
|
typeof process !== "undefined" && process.release.name === "node";
|
||||||
|
|
||||||
function writeNodeLog(
|
function writeNodeLog(
|
||||||
message: string,
|
message: any,
|
||||||
tag: string,
|
tag: string,
|
||||||
level: string,
|
level: string,
|
||||||
args: any[],
|
args: any[],
|
||||||
): void {
|
): void {
|
||||||
process.stderr.write(`${new Date().toISOString()} ${tag} ${level} `);
|
try {
|
||||||
process.stderr.write(message);
|
process.stderr.write(`${new Date().toISOString()} ${tag} ${level} `);
|
||||||
if (args.length != 0) {
|
process.stderr.write(`${message}`);
|
||||||
process.stderr.write(" ");
|
if (args.length != 0) {
|
||||||
process.stderr.write(JSON.stringify(args, undefined, 2));
|
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -919,7 +919,6 @@ export class Wallet {
|
|||||||
/**
|
/**
|
||||||
* Implementation of the "wallet-core" API.
|
* Implementation of the "wallet-core" API.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private async dispatchRequestInternal(
|
private async dispatchRequestInternal(
|
||||||
operation: string,
|
operation: string,
|
||||||
payload: unknown,
|
payload: unknown,
|
||||||
|
Loading…
Reference in New Issue
Block a user