Re: try catch VS __try __except()
sachin wrote:
The document was Good it helped me to understand the difference between
C++ and C Exception handling..
C doesn't have exceptions. What you probably mean is win32 SEH, which is
available as a compiler extension using __try/__except.
but i am still confused about the best way to catch the SE in C++ To be
more specific @ what i want
1. I Agree that Structured Exceptions represent bugs in the program. But
the code is very huge and i hardly have time to run through all Line of
code and check for programming bug :) ..
SEs don't necessarily represent bugs. Also, ignoring them isn't likely to
make your program run any better.
2. The Tool crashes in live environment and causes panic @ client site so
as a short term fix what i want to do is catch those SE in the code and
handle those exception set of documents move them in separate directory
and process next document this way the tool will not stop even though
there is Win32 SE
i have written __try and __except block in main function but i want it
closer to a processing function so that the tool wont stop after exception
and i can restart the function ..
What you could do is
try {
...
} catch(std::exception const& e) {
log("exception: %1", e.what());
...
} catch(...) {
log("unknown exception);
...
}
In any case, there is no guarantee that you can recover from what the SE is
signalling. It could be that it is thrown due to a corrupted stack or
similar things. Just pretending it didn't happen and continuing won't get
you far.
Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Gesch??ftsf??hrer: Thorsten F??cking, Amtsgericht Hamburg HR B62 932