3

I just found this gem in the pile of spaghetti I have to maintain:

try { Foo(); }
catch { throw; }

Is it safe to replace it with

Foo();

?

Ansis Māliņš
  • 1,612
  • 15
  • 35

2 Answers2

9

Yes. It's exactly the same. Maybe someone used it to put a breakpoint in the catch block.

nvoigt
  • 68,786
  • 25
  • 88
  • 134
0

Yes, it is safe to delete try/catch here. Often such code created in iterations: initially it was exceptions processing there, but later it was lazily removed.

ISanych
  • 19,380
  • 4
  • 31
  • 51