Catch clause is redundant

Skip to end of metadata
Go to start of metadata

Consider the following piece of code:

The catch statement may appear to be doing something, but it really isn't: all it's doing is throwing the exception (with the same stack information), which is exactly what would happen if the catch statement weren't written at all.

Please note that if we wrote throw ex instead of just throw, we can no longer argue that the catch clause is redundant.

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Dec 29, 2010

    Should check the differences between stacktraces in either case. Catch clause in general cuts stacktrace leading to the containing frame.