From 87258f571db29fa78f257281d3cfa1d1bd62a01a Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Mon, 5 Oct 2009 23:19:53 +0000 Subject: Improve ability to avoid dialogs in automated tests git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@822086 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/windows/DisableWin32ErrorWindows.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cpp/src/tests/windows/DisableWin32ErrorWindows.cpp') diff --git a/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp b/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp index d51ed90758..a0b665db73 100644 --- a/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp +++ b/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp @@ -28,9 +28,23 @@ #include #include +#include namespace { +// Instead of popping up a window for exceptions, just print something out +LONG _stdcall UnhandledExceptionFilter (PEXCEPTION_POINTERS pExceptionInfo) +{ + DWORD dwExceptionCode = pExceptionInfo->ExceptionRecord->ExceptionCode; + + if (dwExceptionCode == EXCEPTION_ACCESS_VIOLATION) + std::cerr << "\nERROR: ACCESS VIOLATION\n" << std::endl; + else + std::cerr << "\nERROR: UNHANDLED EXCEPTION\n" << std::endl; + + return EXCEPTION_EXECUTE_HANDLER; +} + struct redirect_errors_to_stderr { redirect_errors_to_stderr (); }; @@ -50,6 +64,9 @@ redirect_errors_to_stderr::redirect_errors_to_stderr() // and can't-open-file message boxes. SetErrorMode(SEM_FAILCRITICALERRORS); SetErrorMode(SEM_NOOPENFILEERRORBOX); + + // And this will catch all unhandled exceptions. + SetUnhandledExceptionFilter (&UnhandledExceptionFilter); } } // namespace -- cgit v1.2.1