Hi,
I am working on wrapping an exception over another.
I need a function to which i will be passing my friendly exception message and the exception object.
In that function i should be able to get the wrapped exception details and the parent exception details.
I am breaking my head with this for the past 2 days.
Help needed!!
private void button1_Click(object sender, System.EventArgs e)
{
try
{
try
{
int i = 7;
int j = 0;
int k = i/j;
}
catch (Exception ex)
{
//throw new Exception("The wrapped exception message",ex);
}
}
catch(Exception ex)
{
MessageBox.Show("Error in Demo function");
}
}
Loading
Sylvain BoissePosted Nov 25, 2005, 11:31 AM
class MyException : Exception
{
public MyException(string in_szMessage, Exception in_oParent)
{
m_szMessage = in_szMessage;
m_oParentEx = in_oParent;
}
public string m_szMessage = null;
public Exception m_oParentEx = null;
} private void m_butMyButton_Click(object sender, EventArgs e)
{
try
{
try
{
int i = 7;
int j = 0;
int k = i / j;
} catch (Exception ex)
{
throw new MyException("The wrapped exception message",ex);
}
}
catch (MyException ex)
{
DoWhateverYouWantWith(ex.m_szMessage);
DoWhateverYouWantWith(ex.m_oParentEx);
}