Implement a global exception hook which logs all uncaught exceptions. Fixes #2287.