I searched the forum to see if anyone had inquiried about this before but didn't find. So here's a question.
Is there a reason for re-throwing many of the exceptions caught through-out the code ? I see a lot of this:
catch (WhateverException ex)
{
SomeCleanupCode();
throw ex;
}
And, since the above idiom effectively truncates the stack trace right at the throw statement, I thought it would be more logic to have something like:
catch (WhateverException)
{
SomeCleanupCode();
throw; //just bubblet the exception up
}
OR
catch (WhateverException ex)
{
SomeCleanupCode();
throw new MoreMeaningfulException("Message", ex);
}
OR even (ignoring the original exception):
catch (WhateverException ex)
{
SomeCleanupCode();
throw new MoreMeaningfulException("Message");
}
Well, it has not been a big deal for me now, and I hope it'll never be, but I though I would ask this to understand the code better.
Thanks for an excellent piece of software!!
- Sergio Pereira