Is this a bad practice to catch a non-specific exception such as System.Exception? Why?

前端 未结 8 1321
离开以前
离开以前 2020-11-29 09:21

I am currently doing a code review and the following code made me jump. I see multiple issues with this code. Do you agree with me? If so, how do I explain to my colleague t

8条回答
  •  时光说笑
    2020-11-29 10:14

    the princeple is only to catch the exception you can handle. such as, if you know how to deal with findnotfound, you catch the filenotfoundexception, otherwiese, do NOT catch it and let it be thrown to the upper layer.

提交回复
热议问题