I have 3 Methods, I am try catch for every method. If an error occur in Third method it goes to exception.
private void M1()
{
try
{
//some code
//calling M2()
//some code
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void M2()
{
try
{
//some code
//calling M3()
//some code
}
catch(Exception ex)
{
throw ex;
}
}
private void M3()
{
try
{
//some code
//Error Occur
//some code
}
catch(Exception ex)
{
throw ex;
}
}
Now it goes directly to M1() method and shows Exception. And the another method is
private void M1()
{
try
{
//some code
//calling M2()
//some code
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void M2()
{
try
{
//some code
//calling M3()
//some code
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
}
private void M3()
{
try
{
//some code
//Error Occur
//some code
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
}
After exception also it execute the code in M2() and in M1().
Which Program is best...,