title: Unhandled Error in Node JS Application
body: <p>I have unhandled piece of code in my NodeJS apps data layer that connects to DB. I am explicitly generating error in my code, at the same time not catching it. This is:</p>
  
  <pre><code>AdminRoleData.prototype.getRoleByRoleId = function (params) {
      var connection = new xtrDatabaseConnection();
      var query = "CALL role_getRoleByRoleId(:p_RoleId)";
      var replacements = { p_RoleId: params.roleId };
      replacements = null;
      return connection.executeQuery(query, Sequelize.QueryTypes.RAW, replacements);
  } 
  </code></pre>
  
  <p>replacements = null; this is where i am generating error. No error handling at the moment here. I want to capture these sort of unhandled errors in my application. And want to log them on to file as unhandled exceptions or errors. </p>
  
  <pre><code>process.on('uncaughtException', (err) =&gt; {
      logger.log('whoops! There was an uncaught error', err);
      // do a graceful shutdown,
      // close the database connection etc.
      process.exit(1);
  });
  </code></pre>
  
  <p>My question is that my "uncaughtException" is not getting called. Any help ? Or best practices in such scenarios. Or to catch them globally at some centralized place. </p>