Is “Dying is Awesome” preferred?

后端 未结 16 828
栀梦
栀梦 2020-12-08 11:09

Recently I attended Jeffrey Richter\'s training courses about .NET. He mentions one strategy of coding \"Dying is awesome\". That is, don\'t write \"catch (Exception ex)\" e

16条回答
  •  臣服心动
    2020-12-08 11:48

    That all depends on how you treat exceptions. If you only throw exceptions when something truly exceptional has happened (and not when a database query return no results, or is ill-formed) then you really shouldn't need to ever catch exceptions. Because your program shouldn't be able to recover, anything you can recover from is not an exception, but an error.

提交回复
热议问题