How can I catch a zero-delimited error (and not other errors and access exception information) in Visual Studio 2008 C ++?
I tried this:
try { int j=0; int i= 1/j;//actually, we call a DLL here, which has divide-by-zero } catch(std::exception& e){ printf("%s %s\n", e.what()); } catch(...){ printf("generic exception"); }
But this applies to the general catch block. I understand that MS-specific __try may be useful here somehow, but I would prefer standard C ++, and in any case I have destructors that prevent the use of __try.
CONFIRMATION: The above code is simplified for discussion. Actually, dividing by zero is an error that occurs deep in a third-party DLL for which I have no source code. The error depends on the parameter (handle of complex structure), which I pass to the library, but not in an obvious way. So, I want to be able to gracefully restore.
c ++ exception-handling visual-studio-2008 try-catch
Joshua fox
source share