title: Nodejs uncaughtException event not fired if exception occurred inside express handler
body: <p>I have caught <code>uncaughtException</code> event in my nodejs app to write a log when an exception occurred.</p>
  
  <pre><code>process.on('uncaughtException', (err) =&gt; {
      log.warn('Caught exception. Exiting. error: ' + err + ', stack: ' + err.stack);
      process.exit(1);
  });
  </code></pre>
  
  <p>But, above handler is not called when an exception is thrown inside an express event handler.</p>
  
  <pre><code>someInvalidFunc();    //This causes the uncaughtException handler to get called.
  
  app.all('/ping', function (req, res, next) {
      someInvalidFunc();  //This doesn't cause the uncaughtException handler to get called.
      res.status(200).json({status: 'OK'});
  });
  </code></pre>
  
  <p>Even though the handler is not called, the error is printed to console.</p>
  
  <blockquote>
    <p>Error: ReferenceError: someInvalidFunc is not defined</p>
  </blockquote>
  
  <p>What is the reason for this? How can I catch all unhandled exceptions in the app?</p>