Why catch an exception just to throw it again?

Don't do this.

If you absolutely need to rethrow the exception, just use throw; using throw ex; erases the stack trace and is absolutely wrong.


Probably a bit of code left over from debugging (you'd set a breakpoint on the throw so you could examine the exception in the debugger). I might do something like this if I wanted to log the exception and then pass it up the chain, although I'd probably wrap the exception in another one with a more meaningful (to my application) error message.


I can think of no reason to do this for functionality. However, it can arise when previously there was some error handling (logging usually) that has been removed, and the developer removed the log handling but did not restructure the code to remove the redundant try/catch.