Cache2k在PropagatedCacheException中包装异常,如apidocs中所述。 这导致我需要展开的多层PropagatedCacheExceptions才能获得第一个有意义的原因。
try {
// some long Exceptionchain is thrown
} catch (Throwable e) {
while (e.getCause() instanceof PropagatedCacheException) {
e = e.getCause();
}
Throwable rootCause = e.getCause();
}
有没有更好的方法来做到这一点,或者我错过了一些像public Throwable getFirstCause()
这样可能在其他地方记录的API?我找到了Throwables.getRootCause(),但这不是我想要的,因为我不想要最里面的例外。