Best practices for catching Throwable in Java

后端 未结 4 1507
孤城傲影
孤城傲影 2021-02-05 17:41

Sometimes, you just have to catch Throwable, e.g. when writing a dispatcher queue that dispatches generic items and needs to recover from any errors (said dispatcher logs all ca

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 17:48

    Depends on what you are working on.

    if you are developing an API to be used by some one else, its better to re-throw the Exception or wrap it into a custom exception of yours and throw.

    Whereas if you are developing an enduser application you need to handle this exception and do the needful.

提交回复
热议问题