Node.js - better error handling than process.on('uncaughtException', fn)?

At the top of my app, I have this code:

process.on('uncaughtException', function(err) {
  console.log("We found an uncaught exception.");
  console.log(err);
});

And if I search my logs for grep -i -A10 -B3 'uncaught exception' logfile, I can get some decent info. But I have no idea what execution context the exception got thrown in, what the error was, and so forth.

What pattern should I use instead?

The "err" argument of uncaughtException is an object and you can request some of its properties to get more information for that error. As an example you can use its "stack" property to have a better understanding about where the error is coming from:

console.log(err.stack);

See: http://docs.nodejitsu.com/articles/errors/what-is-the-error-object