|
|
||||||
|
#1
|
|
|
|
|
In my program I'm throwing C++ exceptions all around and need to catch
structured exceptions and re-throw them as C++ exceptions. I've managed to do it, but it's a bit ugly: static DWORD _nExceptionCode; int handler(DWORD code) { _nExceptionCode = code; return EXCEPTION_CONTINUE_SEARCH; } void CatchRun() { __try { Run(); } __except (handler(GetExceptionCode())) { } } now I can ... try { CatchRun(); } catch (...) { throw new FaultStructured(_nExceptionCode); } Is there a 'cleaner' way? Since a catch (...) block does catch structured exceptions, it seems to me there should be a catch (StructuredException& ex) syntax (or some such) that I'm not seeing documented. |
|
|
|
#2
|
|
|
|
|
"Douglas Peterson" <Tergiver> wrote in message
news:2416 > In my program I'm throwing C++ exceptions all around and need to catch > structured exceptions and re-throw them as C++ exceptions. Consider _set_se_translator. The translating function shall be installed on per thread basis. Also note that if you catch SEH exception with __except it's not necessarily true that destructors for automatic objects have been called. Consider compiler's documentation on /EH - <quote> However, some of the unwindable objects in the function where the exception occurs may not get unwound, if the compiler judges their lifetime tracking mechanics to be unnecessary for the synchronous model </quote> In plain English that means that you have to use /EHa if you plan to catch exceptions with __except and treat them as non fatal. -Kirk |
|
|
| Similar Threads | |
| Try-catch works with structured exception Hello everyone, I have tested try-catch works with structured exception, to my surprise. Previously I think we have to use __try and __except. Any comments? Here is my... |
|
| Try-catch works with structured exception Hello everyone, I have tested try-catch works with structured exception, to my surprise. Previously I think we have to use __try and __except. Any comments? Here is my... |
|
| Try-catch works with structured exception Hello everyone, I have tested try-catch works with structured exception, to my surprise. Previously I think we have to use __try and __except. Any comments? Here is my... |
|
| Publish exception to Email in Exception Handling Exception Block Hello and hi everyone.. How can i publish my exception message to email in Exception Handling Application Block?? |
|
| Catch Exception Block Hi, I have created a StringBuilder (Log) in my application that appends all the errors and exceptions in my application. I have included Catch blocks at each sensitive... |
|
|
All times are GMT. The time now is 01:32 AM. | Privacy Policy
|