node js catch any errors

JavaScript
process.on('uncaughtException', function(err) {
  console.log('Caught exception: ' + err);
});
Source

Also in JavaScript: