Java best practices when throwing exceptions: throwing core Java exceptions

后端 未结 5 1142
南方客
南方客 2021-02-02 09:07

Instead of throwing new Exception(\"Some message\", maybeSomeCause), which means that all callers of my method will need to catch Exception (which can include Runti

5条回答
  •  孤街浪徒
    2021-02-02 09:16

    Absolutely it makes sense to reuse Exception classes when they reasonably describe the scenario that caused the exception to be thrown.

提交回复
热议问题