Add event handler to handle uncaught exceptions based on configurations.