I am not sure you have noticed the
difference between throw; and throw ex;. Please look at this example,
class
Program
{
static void Main(string[]
args)
{
try
{
Method1();
}
catch
(Exception ex)
{
}
}
public static void Method1()
{
try
{
Method2();
}
catch (Exception ex)
{
throw ex;
}
}
public static void Method2()
{
Method3();
}
public static void Method3()
{
throw
new Exception("Method3");
}
}
In method1 i am just trying to catch the
exception ex and re-throwing again the same. If you will do so you will miss
something in the stack trace. Here you
will get only Main and Method1, don’t show the methods Method2, M3thod3 which
you have invoked.