它在这里指出:
https://jdbi.org/apidocs/org/jdbi/v3/core/JdbiException.html
那JdbiException
是Base unchecked exception for exceptions thrown from jdbi.
但是,如果我withHandle
使用各种不同的回调调用该方法:
jdbi.withHandle(handle -> handle
.createQuery("...")
.mapTo(String.class)
.one());
文档声明它会抛出X extends Exception
(而不是JdbiExecption
像我预期的那样抛出)并将其描述为@param <X> exception type thrown by the callback, if any.
:
public <R, X extends Exception> R withHandle(HandleCallback<R, X> callback) throws X {
我想知道是否可以安全地打电话withHandle
并抓住JdbiException
,而不是不得不抓住Exception
?
try {
jdbi.withHandle(handle -> ...);
} catch (JdbiException e) {
// Will this catch everything thrown from `withHandle`?
}