Global inactive exception handler in a VC ++ application?

In any case, to catch all uncaught exceptions in an MFC VC ++ 2008 application? There is something like this Java code:

Thread.currentThread().setUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { System.out.println("Oops! We have a exception in Thread '" + t.getName() + "': " + e.toString()); } }); 

The handler should preferably catch all types of exceptions.

+4
source share
1 answer

It depends on what you are trying to catch. If you just want C ++ exceptions, look at customizing your own handlers using set_unexpected or set_terminate . If you want all Windows exceptions, you use SetUnhandledExceptionFilter to specify a top-level handler.

Catching all Windows exceptions should in most cases catch all C ++ exceptions, but this is not always the case, so it is best to use both approaches to catch as much as possible. There are some oddities with the latest CRTs (see this ), which may mean that not all exceptions fall.

+4
source

All Articles