I have one method which throws checked exception:
private void testCacheExpiration() throws InterruptedException
I am trying to create a generic wrapper that will handle the exception gracefully.
private Runnable handleNonTestException(Runnable r) {
return () -> {
try {
r.run();
} catch (Exception e) {
logger.error(NON_TEST_EXCEPTION_MSG, e);
errors.add(new Error(e.getMessage(), NON_TEST_EXCEPTION_MSG));
}
};
}
Now I am using handleNonTestException(this::testCacheExpiration)
which gives me compile time error unhandled exception type: InterruptedException
. What may I be missing?