|
@@ -2,6 +2,7 @@ import winston from "winston";
|
|
import nodemailer from "nodemailer";
|
|
import nodemailer from "nodemailer";
|
|
import TransportStream from "winston-transport";
|
|
import TransportStream from "winston-transport";
|
|
import Mail from "nodemailer/lib/mailer";
|
|
import Mail from "nodemailer/lib/mailer";
|
|
|
|
+import { HTTPError } from "got/dist/source";
|
|
|
|
|
|
export const logger = winston.createLogger({
|
|
export const logger = winston.createLogger({
|
|
level: "debug",
|
|
level: "debug",
|
|
@@ -18,8 +19,14 @@ export const logger = winston.createLogger({
|
|
]
|
|
]
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+function isHttpError(reason?: unknown): reason is HTTPError {
|
|
|
|
+ return reason && Object.prototype.hasOwnProperty.call(reason, "request");
|
|
|
|
+}
|
|
|
|
+
|
|
process.on("unhandledRejection", (reason) => {
|
|
process.on("unhandledRejection", (reason) => {
|
|
- throw reason;
|
|
|
|
|
|
+ if (isHttpError(reason))
|
|
|
|
+ throw new Error(`HTTPError: ${reason.request.requestUrl} failed because ${reason}`);
|
|
|
|
+ throw new Error(`unhandledRejection: ${reason}`);
|
|
});
|
|
});
|
|
|
|
|
|
interface LogMessage {
|
|
interface LogMessage {
|