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
In Java is almost the same:
try { ... } catch (Exception e) { if (e instanceof FooException) throw e; }