Why not catch general Exceptions

后端 未结 12 1680
鱼传尺愫
鱼传尺愫 2020-11-27 16:26

My VS just told me;

Warning 2 CA1031 : Microsoft.Design : Modify \'Program.Main(string[])\' to catch a more specific exception than \'Exception\' or r

12条回答
  •  旧巷少年郎
    2020-11-27 16:43

    When you catch general exceptions, you get the side effect of potentially hiding run-time problems from the user which, in turn, can complicate debugging. Also, by catching general exception, you're ignoring a problem (which you're probably throwing elsewhere).

提交回复
热议问题