15 #ifndef INCG_IRIS_IUTEST_EXCEPTION_HPP_B73B2E25_97C8_4DFC_BC32_5E53039A1A64_
16 #define INCG_IRIS_IUTEST_EXCEPTION_HPP_B73B2E25_97C8_4DFC_BC32_5E53039A1A64_
21 #if IUTEST_HAS_EXCEPTIONS
33 inline ::std::string FormatCxxException(
const char* description)
36 if( description != NULL )
38 strm <<
"C++ exception with description \"" << description <<
"\"";
42 strm <<
"Unknown C++ exception";
50 #if IUTEST_HAS_SEH && IUTEST_HAS_EXCEPTIONS
60 class seh_exception :
public ::std::exception
63 seh_exception() : ::std::exception() {}
64 explicit seh_exception(
const char *
const& _What) : ::std::exception(_What) {}
66 static void translator(DWORD code, _EXCEPTION_POINTERS* ep)
68 IUTEST_UNUSED_VAR(ep);
70 #if IUTEST_HAS_IOMANIP
71 strm <<
"SEH exception with code 0x" << ::std::setbase(16) << code;
73 strm <<
"SEH exception with code " << code;
75 throw seh_exception(strm.str().c_str());
77 static int should_process_through_break_and_cppexceptions(DWORD code)
79 bool should_handle =
true;
81 if( code == EXCEPTION_BREAKPOINT )
82 should_handle =
false;
83 if( code == kCxxExceptionCode )
84 should_handle =
false;
85 return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
88 static const DWORD kCxxExceptionCode = 0xe06d7363;
92 void seh_passthrough(T func)
94 _EXCEPTION_POINTERS* ep = NULL;
99 __except( ep = GetExceptionInformation()
100 , seh_exception::should_process_through_break_and_cppexceptions(GetExceptionCode()) )
102 seh_exception::translator(GetExceptionCode(), ep);
114 #endif // INCG_IRIS_IUTEST_EXCEPTION_HPP_B73B2E25_97C8_4DFC_BC32_5E53039A1A64_