Java, Class-specific Exceptions vs. Standard Exceptions

前端 未结 6 1820
北恋
北恋 2021-02-07 12:42

I\'ve been updating an existing library to throw exceptions to help improve debugging by people using the library.

At first, I thought I\'d define exceptions specific to

6条回答
  •  天涯浪人
    2021-02-07 13:20

    Is it likely that a caller would need to catch FooNegativeIntArgumentException rather than IllegalArgumentException?

    My guess is that it will almost never happen, so I would stick with the basic exceptions until you have cases where such differentiation can be seen to be needed.

提交回复
热议问题