Newer
Older
express-blog / src / utils / logging / handlers.js
@Jason Jason on 24 Jul 461 bytes modified: .gitignore
const UNCUGHT_EXCEPTION_MSG = "Uncaught Exception:";
const UNHANDLED_REJECTION_MSG = "Unhandled Rejection:";

const { winstonLogger } = require("./index");

function handleUncaughtException(err) {
  winstonLogger.error(UNCUGHT_EXCEPTION_MSG, err.stack || err);
}

function handleUnhandledRejection(reason) {
  winstonLogger.error(UNHANDLED_REJECTION_MSG, reason?.stack || reason);
}

module.exports = {
  handleUncaughtException,
  handleUnhandledRejection,
};