C# tips & tricks: Do you want to rethrow exception ?

Many times during development we really don’t want to handle exception every where, rather we like to throw it again. But what is the best way to do it:

catch(Exception ex)
{
throw;
}

OR

catch(Exception ex)
{
throw ex;
}

This article I found in net gives really good insight of it. It suggests to use first method, as it would not truncate previous stack trace information.

Advertisements