Catch and log uncaught exceptions