java.lang.Exception vs. rolling your own exception

后端 未结 10 1203
无人及你
无人及你 2020-12-13 14:30

At what point would you create your own exception class vs. using java.lang.Exception? (All the time? Only if it will be used outside the package? Only if it must contain ad

10条回答
  •  清歌不尽
    2020-12-13 15:00

    I can't imagine specifically throwing a java.lang.Exception if some object/class/method had a problem. It's too generic - if you're not going to create your own Exception class, seems to me like there ought to at least be a more specific Exception-type in the API.

提交回复
热议问题