Rethrowing exceptions and preserving the full call stack trace
Posted by: Fabrice's weblog,
on 02 Jan 2008 |
View original
Did you know that depending on the way you rethrow exceptions you may lose important information? There are already several blog posts that explain and demonstrate the difference between throw and throw ex. I'm realizing only now that none of the two solutions yields the complete call stack trace information!Let's see what the problem is and I'll show you the real solution.I'll use the following method to generate an exception:private static void BadWork(){ int i = 0; int j = 12 / i;...