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,684
  • 15
  • 35

2 Answers2

9

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

nvoigt
  • 75,013
  • 26
  • 93
  • 142
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
  • 21,590
  • 4
  • 32
  • 52