Is it good to catch a more general type of Exception?

后端 未结 10 1709
無奈伤痛
無奈伤痛 2021-01-06 01:22

If we are to catch specific forms of IOException, or any other kind as a matter of fact, and we only try and catch a couple (and define definitive outputs for t

10条回答
  •  北海茫月
    2021-01-06 02:01

    Generally, you should only catch exceptions you are going to handle explicitly.

    You should not catch Exception, IOException, et. al., unless you are an appropriately high level where you are doing your last ditch catch to report a general error to the user.

提交回复
热议问题