Is there any valid reason to ever ignore a caught exception

后端 未结 24 1942
南笙
南笙 2020-11-27 15:43

Wow, I just got back a huge project in C# from outsourced developers and while going through my code review my analysis tool revealed bunches of what it considered bad stuff

24条回答
  •  心在旅途
    2020-11-27 16:04

    My feeling is that any empty Catch Block needs a comment.

    Possibly it's valid to ignore certain errors, but you need to document your reasons.

    Also, you wouldn't want to make it a generic "catch (Exception e) { }".

    You should catch only the specific error type that's expected there and is known to be safely ignored.

提交回复
热议问题