If I have a piece of code which does something like this.
try
{
...
}
catch(Exception ex)
{
throw;
}
The fact that in catch block we are only doing a throw, I cannot seem to find any advantage of this particular exception handler. Are there any peformance issues this unnecessary catch cause to codeflow?
It may cause a performance hit when an exception is thrown – although if an exception is being thrown often enough for that to be a problem, it was probably already a problem beforehand (exceptions should normally not cause a significant performance hit, because they should only be used in exceptional circumstances).
It may cause a performance hit even when an exception isn’t thrown, as it may prevent a method from being inlined.
It does cause a readability/simplicity issue – and that’s the primary reason to get rid of it. Maybe it was there for debugging purposes, but there’s no reason to have it in checked-in code. It’s ugly and pointless, so should definitely be removed.