|
@@ -3,6 +3,7 @@ import nodemailer from "nodemailer";
|
|
|
import TransportStream from "winston-transport";
|
|
|
import Mail from "nodemailer/lib/mailer";
|
|
|
import { isHttpError, hasStackTrace } from "./util";
|
|
|
+import { inspect } from "util";
|
|
|
|
|
|
export const logger = winston.createLogger({
|
|
|
level: "debug",
|
|
@@ -21,11 +22,18 @@ export const logger = winston.createLogger({
|
|
|
});
|
|
|
|
|
|
process.on("unhandledRejection", (reason) => {
|
|
|
+
|
|
|
if (isHttpError(reason))
|
|
|
throw new Error(`HTTPError: ${reason.request.requestUrl} failed because ${reason}\nStack trace: ${reason.stack}`);
|
|
|
if (hasStackTrace(reason))
|
|
|
throw new Error(`Unhandled rejection: ${reason}\nFull stack trace: ${reason.stack}`);
|
|
|
- throw new Error(`Unhandled rejection: ${reason}`);
|
|
|
+ let contents = `${reason}`;
|
|
|
+ try {
|
|
|
+ contents = inspect(reason, true);
|
|
|
+ } catch (e) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
+ throw new Error(`Unhandled rejection: ${contents}`);
|
|
|
});
|
|
|
|
|
|
interface LogMessage {
|