• err {Error} The uncaught exception.
    • origin {string} Indicates if the exception originates from an unhandled rejection or from synchronous errors. Can either be 'uncaughtException' or 'unhandledRejection'. The latter is only used in conjunction with the [--unhandled-rejections][] flag set to strict or throw and an unhandled rejection.

    The 'uncaughtExceptionMonitor' event is emitted before an 'uncaughtException' event is emitted or a hook installed via [process.setUncaughtExceptionCaptureCallback()][] is called.

    Installing an 'uncaughtExceptionMonitor' listener does not change the behavior once an 'uncaughtException' event is emitted. The process will still crash if no 'uncaughtException' listener is installed.

    1. process.on('uncaughtExceptionMonitor', (err, origin) => {
    2. MyMonitoringTool.logSync(err, origin);
    3. });
    4. // Intentionally cause an exception, but don't catch it.
    5. nonexistentFunc();
    6. // Still crashes Node.js