Consider these two models:
1- By re-throwing ex
:
catch(Exception ex)
{
throw ex;
}
you loose StackTrace
. If the exception
is logged somewhere the StackTrace
containing immediate frames of the call stack (history of method calls) is lost.
2- In contrast by throw
:
catch(Exception ex)
{
// do something here
throw;
}
you maintain StackTrace
. You can do additional processing and then re-throw the exception
without loosing the trace string.