Is there any valid reason to ever ignore a caught exception

后端 未结 24 1952
南笙
南笙 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:09

    One example of where I'd consider this acceptable is in some non-critical module of a critical application (say, in the sound feedback module of the space shuttle navigation system), for exceptions that should never happen, and cannot be handled more cleanly.

    In those cases, you would not want to let that exception propagate and cause the whole application to fail (Sorry guys, no more navigation system, our beeping module crashed, and there was really nothing we could do about it).

    Edited to say that in any of these cases, you'd at least want to log the event somewhere.

提交回复
热议问题