JetBrains Rider 2018.1 Help

Code Inspection: Redundant catch clause

Consider the following piece of code:

try { string s = File.ReadAllText("test.txt"); } catch (Exception ex) { throw; }

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.

Last modified: 20 August 2018

See Also