unhandeld exception
-
Hi there, i have a really annoying problem with exceptions. On my system (Windows 2000, VS 6, SP3) the following code produces an unhandeld C++ exception: class TEST { public: TEST() {}; }; try { TRACE("before throw TEST\n"); throw TEST(); } catch (TEST x) { TRACE ("test catched\n"); } catch (...) { TRACE ("unkown catched\n"); } TRACE("after throw TEST\n"); The debug window shows the following: >before throw TEST >test catched >after throw TEST >Nicht abgefangene Ausnahme in TESTEXCEP.exe (KERNEL32.DLL): 0xE06D7363: >Microsoft C++ Exception. What's going wrong? Any help is welcome. Thanx Klaus
-
Hi there, i have a really annoying problem with exceptions. On my system (Windows 2000, VS 6, SP3) the following code produces an unhandeld C++ exception: class TEST { public: TEST() {}; }; try { TRACE("before throw TEST\n"); throw TEST(); } catch (TEST x) { TRACE ("test catched\n"); } catch (...) { TRACE ("unkown catched\n"); } TRACE("after throw TEST\n"); The debug window shows the following: >before throw TEST >test catched >after throw TEST >Nicht abgefangene Ausnahme in TESTEXCEP.exe (KERNEL32.DLL): 0xE06D7363: >Microsoft C++ Exception. What's going wrong? Any help is welcome. Thanx Klaus
Hello Klaus, What do you really expect of the program? To me, not an expert in exceptions anyway, it is the normal flow. Probably you may gain some confidence from the ff. MS own codes under the topic "C++ Exception Examples"... Check the MSDN for the expected results and see how this is different or similar to yours. Again, I am not an expert, so take this as my humble piece!!! #include void MyFunc( void ); class CTest { public: CTest(){}; ~CTest(){}; const char *ShowReason() const { return "Exception in CTest class."; } }; class CDtorDemo { public: CDtorDemo(); ~CDtorDemo(); }; CDtorDemo::CDtorDemo() { cout << "Constructing CDtorDemo." << endl; } CDtorDemo::~CDtorDemo() { cout << "Destructing CDtorDemo." << endl; } void MyFunc() { CDtorDemo D; cout<< "In MyFunc(). Throwing CTest exception." << endl; throw CTest(); } int main() { cout << "In main." << endl; try { cout << "In try block, calling MyFunc()." << endl; MyFunc(); } catch( CTest E ) { cout << "In catch handler." << endl; cout << "Caught CTest exception type: "; cout << E.ShowReason() << endl; } catch( char *str ) { cout << "Caught some other exception: " << str << endl; } cout << "Back in main. Execution resumes here." << endl; return 0; }