I have created a DLL with Visual C++ 6. It is a standard Win32 DLL, not using
MFC.
The exported function of my DLL are "extern C" functions, to be used from
pure C (not C++) code.
For this reason, I don't want exceptions to traverse the boundary of my DLL.
So, I have included the following code in all my exported functions :
extern "C" void exportedFunction()
{
try
{
// The code body ...
}
catch ( MyException& e )
{
// Here, I handle my own exceptions.
}
catch ( ... )
{
// Here, I handle unknown exception.
}
}
The problem is that, when the catch (...) is reached, I have no information
about the problem that occured. The only treatment I can do is logging a
general message like "Unexpected exception thrown".
My question is :
How can I obtain information about the exception in order to create a
precise message ?
In my DLL I use Win32 functions like EnterCriticalSection for example, and I
have read in the documentation that this function can raise exception ("This
function can raise EXCEPTION_POSSIBLE_DEADLOCK if the critical section is
corrupt").
Should I reread my 200000 lines source code to see all the Win32 functions I
am using, then read the documentation of each function to know which
exception they can raise, and finally put a dedicated catch block for each
exception ???