Is there any valid reason to ever ignore a caught exception

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

    Unless your catch code will either

    1. Log the exception
    2. Repackage the exception into another exception that matches the same abstraction. and throw again
    3. Handles the exception the way you see suitable

    You can ignore the exception, but at least mention the expected exception in the method docs, so the consumer can expect and handle if necessary

提交回复
热议问题