Package org.kiwiproject.base
Interface CatchingRunnable
-
- All Superinterfaces:
Runnable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface CatchingRunnable extends Runnable
Extension ofRunnablethat never lets exceptions escape. Useful for things like scheduled executions usingScheduledExecutorServicewhere an intermittent error should not cause the executor to suppress future executions (which is the default behavior).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidhandleExceptionSafely(Throwable throwable)Handle an exception thrown byrunSafely().default voidrun()WrapsrunSafely()in a try/catch.voidrunSafely()The logic that could throw aRuntimeException.
-
-
-
Method Detail
-
run
default void run()
WrapsrunSafely()in a try/catch. Logs exceptions and will callhandleExceptionSafely(Throwable)to permit handling of any thrown exceptions.
-
handleExceptionSafely
default void handleExceptionSafely(Throwable throwable)
Handle an exception thrown byrunSafely().- Parameters:
throwable- theThrowableto handle
-
runSafely
void runSafely()
The logic that could throw aRuntimeException.
-
-