When I throw an exception in a library, that exception does not get caught by the caller.
To illustrate, if I have this function in a static library:
#include <exception>
void TestClass::ThrowException()
{
throw new std::exception();
}
... and then call it from an executable:
TestClass t;
try
{
t.ThrowException();
}
catch (std::exception e)
{
}
catch (...)
{
}
... it is the second catch that receives the exception, not the first, which I did not expect. I suspect that there is some marshalling between the libraries that I am not aware of, which is causing the exception type to not be recognised.
Is it possible to pass an exception between two binaries so that it is recognised as a 'std::exception' by the caller? As a secondary question, is this a good idea?
I am targeting Windows, working with Visual Studio.