R
reuce-google
Hi folks,
I want to store an exception and rethrow it later:
CException m_pEc = NULL; // Class variable.
try
{
throw new CMemoryException();
}
catch (CException * pEc) // Catch all exceptions derived from
CException.
{
m_pEc = pEc; // Store Exception.
}
.....
CMemoryException is derived from CException. But if I now throw m_pEc
the Exception raised will be caught merely by CException catch blocks,
unfortunately:
try
{
CException * pEc = m_pEc;
m_pEc = NULL; // Clear variable.
throw pEc;
}
catch (CMemoryException * pEc)
{
// Won't catch the exception.
}
catch (CException * pEc)
{
// Will catch the exception.
}
.....
How can I rethrow the exception, so that it will be thrown with the
right type information (CMemoryException) - even if I don't know the
type beforehand?
I want to store an exception and rethrow it later:
CException m_pEc = NULL; // Class variable.
try
{
throw new CMemoryException();
}
catch (CException * pEc) // Catch all exceptions derived from
CException.
{
m_pEc = pEc; // Store Exception.
}
.....
CMemoryException is derived from CException. But if I now throw m_pEc
the Exception raised will be caught merely by CException catch blocks,
unfortunately:
try
{
CException * pEc = m_pEc;
m_pEc = NULL; // Clear variable.
throw pEc;
}
catch (CMemoryException * pEc)
{
// Won't catch the exception.
}
catch (CException * pEc)
{
// Will catch the exception.
}
.....
How can I rethrow the exception, so that it will be thrown with the
right type information (CMemoryException) - even if I don't know the
type beforehand?