lib/interfaces/uncaught.js
function handlerSetup(client, config) {
  /**
   * The actual exception handler creates a new instance of `ErrorMessage`,
   * extracts infomation from the propagated `Error` and marshals it into the
   * `ErrorMessage` instance, attempts to send this `ErrorMessage` instance to
   * the Stackdriver Error Reporting API. Subsequently the process is
   * terminated.
   * @function uncaughtExceptionHandler
   * @listens module:process~event:uncaughtException
   * @param {Error} err - The error that has been uncaught to this point
   * @returns {Undefined} - does not return a value
   */
  function uncaughtExceptionHandler(err) {
    var em = new ErrorMessage();

    errorHandlerRouter(err, em);
    client.sendError(em, handleProcessExit);
    setTimeout(handleProcessExit, 2000);
  }

  if (!config.getReportUncaughtExceptions()) {
    // Do not attach a listener to the process
    return null;
  }

  return process.on('uncaughtException', uncaughtExceptionHandler);
}
function handlerSetup(client, config) {
  /**
   * The actual exception handler creates a new instance of `ErrorMessage`,
   * extracts infomation from the propagated `Error` and marshals it into the
   * `ErrorMessage` instance, attempts to send this `ErrorMessage` instance to
   * the Stackdriver Error Reporting API. Subsequently the process is
   * terminated.
   * @function uncaughtExceptionHandler
   * @listens module:process~event:uncaughtException
   * @param {Error} err - The error that has been uncaught to this point
   * @returns {Undefined} - does not return a value
   */
  function uncaughtExceptionHandler(err) {
    var em = new ErrorMessage();

    errorHandlerRouter(err, em);
    client.sendError(em, handleProcessExit);
    setTimeout(handleProcessExit, 2000);
  }

  if (!config.getReportUncaughtExceptions()) {
    // Do not attach a listener to the process
    return null;
  }

  return process.on('uncaughtException', uncaughtExceptionHandler);
}
function handlerSetup ( client , config ) { /**
   * The actual exception handler creates a new instance of `ErrorMessage`,
   * extracts infomation from the propagated `Error` and marshals it into the
   * `ErrorMessage` instance, attempts to send this `ErrorMessage` instance to
   * the Stackdriver Error Reporting API. Subsequently the process is
   * terminated.
   * @function uncaughtExceptionHandler
   * @listens module:process~event:uncaughtException
   * @param {Error} err - The error that has been uncaught to this point
   * @returns {Undefined} - does not return a value
   */ function uncaughtExceptionHandler ( err ) { var em = new ErrorMessage ( ) ; errorHandlerRouter ( err , em ) ; client . sendError ( em , handleProcessExit ) ; setTimeout ( handleProcessExit , 2000 ) ; } if ( ! config . getReportUncaughtExceptions ( ) ) { // Do not attach a listener to the process return null ; } return process . on ( 'uncaughtException' , uncaughtExceptionHandler ) ; }
If the configuraiton allows, install an uncaught exception handler that will
report the uncaught error to the API and then terminate the process.
@function handlerSetup
@param {AuthClient} client - the API client for communication with the
Stackdriver Error API
@param {Configuration} config - the init configuration
@returns {Null|process} - Returns null if the config demands ignoring
uncaught
exceptions, otherwise return the process instance
If the configuraiton allows install an uncaught exception handler that will report the uncaught error to the API and then terminate the process .