I get an error on my unit test and it hangs my TeamCity continuous integration. How can I make it error headlessly? Fixing the error is a separate issue, please don't tell me that.
The easiest solution is very likely to use SetErrorMode
(with - at least - SEM_NOGPFAULTERRORBOX
) to shut up any such error dialogs (see the flags in the MSDN docs) and silently have the process terminated.
Another option is to install your own top-level exception handler. In XP and newer you can use vectored exception handling. On any system including those newer ones you can use SetUnhandledExceptionFilter
.
Part V, particularly chapter 25, of "Windows via C++" by Richter and Nasarre discusses the topic at great length and detail. The particular topic of WER and top-level exception handlers is also discussed in "Advanced Windows Debugging" (though from a different perspective).