Another good option is to use AddVectoredExceptionHandler. This is essentially the same exception handler that @Alexey Frunze demonstrated, but it doesn't require a __try/__except block, and can be installed globally in the application and removed when no longer needed.