In C#, I can use the throw; statement to rethrow an exception while preserving the stack trace:
throw;
try { ... } catch (Exception e) { if (e is
catch (WhateverException e) { throw e; }
will simply rethrow the exception you've caught (obviously the surrounding method has to permit this via its signature etc.). The exception will maintain the original stack trace.