When to use custom exceptions vs. existing exceptions vs. generic exceptions

后端 未结 5 2083
遥遥无期
遥遥无期 2020-12-14 04:05

I\'m trying to figure out what the correct form of exceptions to throw would be for a library I am writing. One example of what I need to handle is logging a user in to a st

5条回答
  •  旧时难觅i
    2020-12-14 04:42

    I think you need to have one base exception and one subtype exception for each of the situalitions you describe (actually you can make db down and internal db error to have the same base exception). The key point is that it is good practice to have your own exceptions for your library.

提交回复
热议问题