public class Inhibit extends Object
Inhibit
class defines methods that can be used for properly
inhibiting errors and/or conditions in specific situations based on standard
algorithms for doing so.Modifier and Type | Method and Description |
---|---|
static void |
exceptionsWhileClosing(InputStream is)
Inhibits exceptions while closing the specified input stream.
|
static void |
exceptionsWhileClosing(Reader r)
Inhibits exceptions while closing the specified reader.
|
static <E extends Throwable> |
interruptions(E2Runnable<E,InterruptedException> cmd,
EConsumer<InterruptedException,E> handle)
Invokes the specified command while inhibiting Java interruptions and
propagating them after.
|
static <E extends Exception> |
interruptionsAndExceptions(ERunnable<Exception> cmd,
EConsumer<Exception,E> handle)
Invokes the specified command while inhibiting Java exceptions and
interruptions and propagating the interruptions properly after; runtime
exceptions are still propagated as expected.
|
static <T,E extends Exception> |
interruptionsAndExceptionsAndReturn(ESupplier<T,Exception> cmd,
EFunction<Exception,T,E> handle)
Invokes the specified operation while inhibiting Java exceptions and
interruptions and propagating the interruptions properly after; runtime
exceptions are still propagated as expected.
|
static <T,E extends Throwable> |
interruptionsAndReturn(E2Supplier<T,E,InterruptedException> cmd,
EFunction<InterruptedException,T,E> handle)
Invokes the specified operation while inhibiting Java interruptions and
propagating them after.
|
static <E extends Exception> |
interruptionsAndThrowOtherWhileSleeping(long delay,
E e)
Invokes
Thread.sleep(long) while inhibiting interruptions while
propagating them properly for the next level. |
static <E extends Throwable> |
interruptionsWhileRetrying(E2Runnable<E,InterruptedException> cmd)
Invoked the specified command object while inhibiting Java interruptions
and propagating them after.
|
static <E extends Exception> |
interruptionsWhileRetryingAndExceptions(ERunnable<Exception> cmd,
EConsumer<Exception,E> handle)
Invokes the specified command while inhibiting Java exceptions and
interruptions and propagating the interruptions properly after.
|
static <T,E extends Exception> |
interruptionsWhileRetryingAndExceptionsAndReturn(ESupplier<T,Exception> cmd,
EFunction<Exception,T,E> handle)
Invokes the specified operation while inhibiting Java exceptions and
interruptions and propagating the interruptions properly after.
|
static <T,E extends Throwable> |
interruptionsWhileRetryingAndReturn(E2Supplier<T,E,InterruptedException> cmd)
Invoked the specified operation object while inhibiting Java interruptions
and propagating them after.
|
static boolean |
interruptionsWhileRetryingTryingLock(Lock lock,
long time,
TimeUnit unit)
Invokes
Lock.tryLock() while inhibiting Java interruptions
and propagating them after. |
static <T> T |
interruptionsWhileRetryingWaitingFor(Future<T> future)
Invokes
Future.get() while inhibiting Java interruptions
and propagating them after. |
static <T> T |
interruptionsWhileRetryingWaitingFor(Future<T> future,
long time,
TimeUnit unit)
Invokes
Future.get() while inhibiting Java interruptions
and propagating them after. |
static void |
interruptionsWhileRetryingWaitingForNotificationFrom(Object obj)
Invokes
Object.wait(long) while inhibiting Java interruptions
and propagating them after. |
static void |
interruptionsWhileSleeping(long delay)
Invokes
Thread.sleep(long) while inhibiting interruptions while
propagating them properly for the next level. |
static boolean |
interruptionsWhileTryingLock(Lock lock,
long time,
TimeUnit unit)
Invokes
Lock.tryLock() while inhibiting Java interruptions
and propagating them after. |
static <T> T |
interruptionsWhileWaitingFor(Future<T> future)
Invokes
Future.get() while inhibiting Java interruptions
and propagating them after. |
static <T> T |
interruptionsWhileWaitingFor(Future<T> future,
long time,
TimeUnit unit)
Invokes
Future.get() while inhibiting Java interruptions
and propagating them after. |
static void |
interruptionsWhileWaitingForNotificationFrom(Object obj)
Invokes
Object.wait(long) while inhibiting Java interruptions
and propagating them after. |
static void |
throwables(ERunnable<Throwable> cmd)
Invokes the specified command while inhibiting Java errors and
exceptions.
|
static <E extends Throwable> |
throwables(ERunnable<Throwable> cmd,
EConsumer<Throwable,E> handle)
Invokes the specified command while inhibiting Java errors and
exceptions.
|
static <T,E extends Throwable> |
throwables(T arg,
EConsumer<T,Throwable> cmd,
EConsumer<Throwable,E> handle)
Invokes the specified consumer while inhibiting Java errors and
exceptions.
|
static <T,E extends Throwable> |
throwablesAndReturn(ESupplier<T,Throwable> cmd,
EFunction<Throwable,T,E> handle)
Invokes the specified operation while inhibiting Java errors and
exceptions.
|
static <T,R,E extends Throwable> |
throwablesAndReturn(T arg,
EFunction<T,R,Throwable> cmd,
EFunction<Throwable,R,E> handle)
Invokes the specified function while inhibiting Java errors and
exceptions.
|
static <E extends Throwable> |
unwrappedThrowables(ERunnable<Throwable> cmd,
EConsumer<Throwable,E> handle)
Invokes the specified command while inhibiting Java errors, exceptions,
and unwrapping target exceptions.
|
static <T,E extends Throwable> |
unwrappedThrowables(T arg,
EConsumer<T,Throwable> cmd,
EConsumer<Throwable,E> handle)
Invokes the specified consumer while inhibiting Java errors, exceptions,
and unwrapping target exceptions.
|
static <T,E extends Throwable> |
unwrappedThrowablesAndReturn(ESupplier<T,Throwable> cmd,
EFunction<Throwable,T,E> handle)
Invokes the specified operation while inhibiting Java errors, exceptions,
and unwrapping target exceptions.
|
static <T,R,E extends Throwable> |
unwrappedThrowablesAndReturn(T arg,
EFunction<T,R,Throwable> cmd,
EFunction<Throwable,R,E> handle)
Invokes the specified function while inhibiting Java errors, exceptions,
and unwrapping target exceptions.
|
public static void interruptionsWhileSleeping(long delay)
Thread.sleep(long)
while inhibiting interruptions while
propagating them properly for the next level.
Note: If interrupted, the control is returned right away after having propagated the interruption via the thread's interrupted flag.
delay
- the number of milliseconds to sleep forpublic static <E extends Exception> void interruptionsAndThrowOtherWhileSleeping(long delay, E e) throws E extends Exception
Thread.sleep(long)
while inhibiting interruptions while
propagating them properly for the next level. The specified exception is
thrown in place of the interruption.
Note: If interrupted, the control is returned right away via the specified exception after having propagated the interruption via the thread's interrupted flag.
E
- the type of error to throw in case of interruptionse
- the exception to throw if interrupteddelay
- the number of milliseconds to sleep forE
- as e
if an interruption is detected which will be attached
as the root causeE extends Exception
public static final boolean interruptionsWhileTryingLock(Lock lock, long time, TimeUnit unit)
Lock.tryLock()
while inhibiting Java interruptions
and propagating them after.
Note: If interrupted, the control is returned right away after
having propagated the interruption properly and false
is
returned.
lock
- the lock to try to acquiretime
- the maximum time to wait for the lockunit
- the units of timetrue
if the lock was acquired and false
if the waiting time elapsed before the lock was acquired or if the
thread was interruptedNullPointerException
- if lock
is null
public static final void interruptionsWhileWaitingForNotificationFrom(Object obj)
Object.wait(long)
while inhibiting Java interruptions
and propagating them after.
Note: If interrupted, the control is returned right away after
having propagated the interruption properly and null
is
returned.
obj
- the object to wait for a notificationNullPointerException
- if obj
is null
public static final <T> T interruptionsWhileWaitingFor(Future<T> future) throws ExecutionException
Future.get()
while inhibiting Java interruptions
and propagating them after.
Note: If interrupted, the control is returned right away after
having propagated the interruption properly and null
is
returned.
T
- the type of result computed by the futurefuture
- the future to try to getnull
if the waiting time elapsed before the future returned or if the
thread was interruptedExecutionException
- if the computation threw an exceptionNullPointerException
- if future
is null
public static final <T> T interruptionsWhileWaitingFor(Future<T> future, long time, TimeUnit unit) throws ExecutionException, TimeoutException
Future.get()
while inhibiting Java interruptions
and propagating them after.
Note: If interrupted, the control is returned right away after
having propagated the interruption properly and null
is
returned.
T
- the type of result computed by the futurefuture
- the future to try to gettime
- the maximum time to wait for the futureunit
- the units of timenull
if the waiting time elapsed before the future returned or if the
thread was interruptedExecutionException
- if the computation threw an exceptionTimeoutException
- if the wait timed outNullPointerException
- if future
is null
public static final <T,E extends Throwable> T interruptionsAndReturn(E2Supplier<T,E,InterruptedException> cmd, EFunction<InterruptedException,T,E> handle) throws E extends Throwable
Interruptions from the operation are handled by calling the handle function and then propagated properly.
Note: Any runtime exceptions or errors thrown out of the handle function will be automatically thrown out.
T
- the type of result returned by cmd
E
- the type of exceptions that can be thrown outcmd
- the non-null
operation to inhibit interruptions forhandle
- the non-null
function to handle any interruptions
that occurs when calling the operationc
or by handle
if
an interruption occursE
- if an error occurs while executing the operationRuntimeException
- if cmd
throws a runtime exceptionError
- if cmd
throws an errorNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final <E extends Throwable> void interruptions(E2Runnable<E,InterruptedException> cmd, EConsumer<InterruptedException,E> handle) throws E extends Throwable
Interruptions from the operation are handled by calling the handle consumer and then propagated properly.
Note: Any runtime exceptions or errors thrown out of the handle consumer will be automatically thrown out.
E
- the type of exceptions that can be thrown outcmd
- the non-null
operation to inhibit interruptions forhandle
- the non-null
consumer to handle any interruptions
that occurs when calling the operationE
- if an error occurs while executing the operationRuntimeException
- if cmd
throws a runtime exceptionError
- if cmd
throws an errorNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final <T,E extends Exception> T interruptionsAndExceptionsAndReturn(ESupplier<T,Exception> cmd, EFunction<Exception,T,E> handle) throws E extends Exception
Non-runtime exceptions from the operation are handled by calling the handle function.
Note: Any runtime exceptions or errors thrown out of the handle function will be automatically thrown out.
T
- the type of result returned by cmd
E
- the type of exceptions that can be thrown outcmd
- the non-null
operation to inhibit interruptions and
exceptions forhandle
- the non-null
function to handle any exceptions
that occurs when calling the operationcmd
or from the handle
if a non runtime exception or an interruption occursE
- if thrown by the handle functionRuntimeException
- if cmd
or handle
throws
a runtime exceptionError
- if cmd
or handle
throws an errorNullPointerException
- if cmd
or handle
is
null
E extends Exception
public static final <E extends Exception> void interruptionsAndExceptions(ERunnable<Exception> cmd, EConsumer<Exception,E> handle) throws E extends Exception
Non-runtime exceptions from the operation are handled by calling the handle consumer.
Note: Any runtime exceptions or errors thrown out of the handle consumer will be automatically thrown out.
E
- the type of exceptions that can be thrown outcmd
- the non-null
command to inhibit interruptions and
exceptions forhandle
- the non-null
consumer to handle any exceptions
that occurs when calling the operationE
- if thrown by the handle functionRuntimeException
- if cmd
or handle
throws
a runtime exceptionError
- if cmd
or handle
throws an errorNullPointerException
- if cmd
or handle
is
null
E extends Exception
public static final <T,E extends Throwable> T interruptionsWhileRetryingAndReturn(E2Supplier<T,E,InterruptedException> cmd) throws E extends Throwable
T
- the type of result returned by cmd
E
- the type of exceptions that can be thrown outcmd
- the non-null
operation to inhibit interruptions forcmd
E
- if an error occurs while executing the operationRuntimeException
- if cmd
throws a runtime exceptionError
- if cmd
throws an errorNullPointerException
- if cmd
is null
E extends Throwable
public static final <E extends Throwable> void interruptionsWhileRetrying(E2Runnable<E,InterruptedException> cmd) throws E extends Throwable
E
- the type of exceptions that can be thrown outcmd
- the non-null
command to inhibit interruptions forE
- if an error occurs while executing the commandRuntimeException
- if cmd
throws a runtime exceptionError
- if cmd
throws an errorNullPointerException
- if cmd
is null
E extends Throwable
public static final boolean interruptionsWhileRetryingTryingLock(Lock lock, long time, TimeUnit unit)
Lock.tryLock()
while inhibiting Java interruptions
and propagating them after. This version of the method will
retry trying the lock if an interruption occurs.lock
- the lock to try to acquiretime
- the maximum time to wait for the lockunit
- the units of timetrue
if the lock was acquired and false
if the waiting time elapsed before the lock was acquired or if the
thread was interruptedNullPointerException
- if lock
is null
public static final <T> T interruptionsWhileRetryingWaitingFor(Future<T> future) throws ExecutionException
Future.get()
while inhibiting Java interruptions
and propagating them after. This version of the method will
retry waiting for the future result if an interruption occurs.T
- the type of result computed by the futurefuture
- the future to try to getnull
if the waiting time elapsed before the future returned or if the
thread was interruptedExecutionException
- if the computation threw an exceptionNullPointerException
- if future
is null
public static final <T> T interruptionsWhileRetryingWaitingFor(Future<T> future, long time, TimeUnit unit) throws ExecutionException, TimeoutException
Future.get()
while inhibiting Java interruptions
and propagating them after. This version of the method will
retry waiting for the future result if an interruption occurs.T
- the type of result computed by the futurefuture
- the future to try to gettime
- the maximum time to wait for the futureunit
- the units of timenull
if the waiting time elapsed before the future returned or if the
thread was interruptedExecutionException
- if the computation threw an exceptionTimeoutException
- if the wait timed outNullPointerException
- if future
is null
public static final void interruptionsWhileRetryingWaitingForNotificationFrom(Object obj)
Object.wait(long)
while inhibiting Java interruptions
and propagating them after. This version of the method will
retry waiting for notifications from the object if an interruption occurs.obj
- the object to wait for a notificationNullPointerException
- if obj
is null
public static final <T,E extends Exception> T interruptionsWhileRetryingAndExceptionsAndReturn(ESupplier<T,Exception> cmd, EFunction<Exception,T,E> handle) throws E extends Exception
Non-runtime exceptions from the operation are handled by calling the handle function.
Note: Any runtime exceptions or errors thrown out of the handle function will be automatically thrown out.
T
- the type of result returned by cmd
E
- the type of exceptions that can be thrown outcmd
- the non-null
operation to inhibit interruptions
and exceptions forhandle
- the non-null
function to handle any exceptions
that occurs when calling the operationcmd
or from the handle
if a non runtime exception occursE
- if thrown by the handle functionRuntimeException
- if cmd
or handle
throws
a runtime exceptionError
- if cmd
or handle
throws an errorNullPointerException
- if cmd
or handle
is
null
E extends Exception
public static final <E extends Exception> void interruptionsWhileRetryingAndExceptions(ERunnable<Exception> cmd, EConsumer<Exception,E> handle) throws E extends Exception
Non-runtime exceptions from the operation are handled by calling the handle consumer.
Note: Any runtime exceptions or errors thrown out of the handle consumer will be automatically thrown out.
E
- the type of exceptions that can be thrown outcmd
- the non-null
command to inhibit interruptions
and exceptions forhandle
- the non-null
consumer to handle any exceptions
that occurs when calling the operationE
- if thrown by the handle consumerRuntimeException
- if cmd
or handle
throws
a runtime exceptionError
- if cmd
or handle
throws an errorNullPointerException
- if cmd
or handle
is
null
E extends Exception
public static final void exceptionsWhileClosing(Reader r)
r
- the reader to be closedpublic static final void exceptionsWhileClosing(InputStream is)
is
- the input stream to be closedpublic static final <T,E extends Throwable> T throwablesAndReturn(ESupplier<T,Throwable> cmd, EFunction<Throwable,T,E> handle) throws E extends Throwable
OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions from the operation are handled by calling the handle function.
T
- the type of result returned by cmd
E
- the type of exceptions that can be thrown outcmd
- the non-null
operation to execute and inhibit
errors and exceptions forhandle
- the non-null
function to handle any other exceptions
or errors that occurs when calling the operationcmd
or handle
E
- if thrown by the handle functionNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final <E extends Throwable> void throwables(ERunnable<Throwable> cmd, EConsumer<Throwable,E> handle) throws E extends Throwable
OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions from the command are handled by calling the handle consumer.
E
- the type of exceptions that can be thrown outcmd
- the non-null
command to execute and inhibit
errors and exceptions forhandle
- the non-null
consumer to handle any other exceptions
or errors that occurs when calling the operationE
- if thrown by the handle consumerNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final void throwables(ERunnable<Throwable> cmd)
OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions are simply ignored.
cmd
- the non-null
command to execute and inhibit
errors and exceptions forNullPointerException
- if cmd
or handle
is
null
public static final <T,R,E extends Throwable> R throwablesAndReturn(T arg, EFunction<T,R,Throwable> cmd, EFunction<Throwable,R,E> handle) throws E extends Throwable
OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions from the operation are handled by calling the handle function.
T
- the type of argument passed to cmd
R
- the type of result returned by cmd
E
- the type of exceptions that can be thrown outarg
- the argument to pass to the functioncmd
- the non-null
function to execute and inhibit
errors and exceptions forhandle
- the non-null
function to handle any other exceptions
or errors that occurs when calling the operationcmd
or handle
E
- if thrown by the handle functionNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final <T,E extends Throwable> void throwables(T arg, EConsumer<T,Throwable> cmd, EConsumer<Throwable,E> handle) throws E extends Throwable
OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions from the consumer are handled by calling the handle consumer.
T
- the type of argument passed to cmd
E
- the type of exceptions that can be thrown outarg
- the argument to pass to the consumercmd
- the non-null
consumer to execute and inhibit
errors and exceptions forhandle
- the non-null
consumer to handle any other exceptions
or errors that occurs when calling the consumerE
- if thrown by the handle consumerNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final <T,E extends Throwable> T unwrappedThrowablesAndReturn(ESupplier<T,Throwable> cmd, EFunction<Throwable,T,E> handle) throws E extends Throwable
InvocationTargetException
are first unwrapped by calling
InvocationTargetException.getTargetException()
.
- ExceptionInInitializerError
are first unwrapped by calling
ExceptionInInitializerError.getException()
.
- OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions from the operation are handled by calling the handle function.
T
- the type of result returned by cmd
E
- the type of exceptions that can be thrown outcmd
- the non-null
operation to execute and inhibit
errors and exceptions forhandle
- the non-null
function to handle any other exceptions
or errors that occurs when calling the operationcmd
or handle
E
- if thrown by the handle functionNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final <E extends Throwable> void unwrappedThrowables(ERunnable<Throwable> cmd, EConsumer<Throwable,E> handle) throws E extends Throwable
InvocationTargetException
are first unwrapped by calling
InvocationTargetException.getTargetException()
.
- ExceptionInInitializerError
are first unwrapped by calling
ExceptionInInitializerError.getException()
.
- OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions from the command are handled by calling the handle consumer.
E
- the type of exceptions that can be thrown outcmd
- the non-null
command to execute and inhibit
errors and exceptions forhandle
- the non-null
consumer to handle any other exceptions
or errors that occurs when calling the operationE
- if thrown by the handle consumerNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final <T,R,E extends Throwable> R unwrappedThrowablesAndReturn(T arg, EFunction<T,R,Throwable> cmd, EFunction<Throwable,R,E> handle) throws E extends Throwable
InvocationTargetException
are first unwrapped by calling
InvocationTargetException.getTargetException()
.
- ExceptionInInitializerError
are first unwrapped by calling
ExceptionInInitializerError.getException()
.
- OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions from the operation are handled by calling the handle function.
T
- the type of argument passed to cmd
R
- the type of result returned by cmd
E
- the type of exceptions that can be thrown outarg
- the argument to pass to the functioncmd
- the non-null
function to execute and inhibit
errors and exceptions forhandle
- the non-null
function to handle any other exceptions
or errors that occurs when calling the operationcmd
or handle
E
- if thrown by the handle functionNullPointerException
- if cmd
or handle
is
null
E extends Throwable
public static final <T,E extends Throwable> void unwrappedThrowables(T arg, EConsumer<T,Throwable> cmd, EConsumer<Throwable,E> handle) throws E extends Throwable
InvocationTargetException
are first unwrapped by calling
InvocationTargetException.getTargetException()
.
- ExceptionInInitializerError
are first unwrapped by calling
ExceptionInInitializerError.getException()
.
- OutOfMemoryError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. Attempting to do anything
else can cause additional memory issues and corruption.
- StackOverflowError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up.
- AssertionError
are not intercepted; nor are they logged. These
are thrown back as they should propagate up so JUnit test case can
stopped when an assertion fails.
- ThreadDeath
are not intercepted; nor are they logged. These
are thrown back as they should propagate up. These errors are part of Java's
mechanism for stopping threads.
All other errors and exceptions from the consumer are handled by calling the handle consumer.
T
- the type of argument passed to cmd
E
- the type of exceptions that can be thrown outarg
- the argument to pass to the consumercmd
- the non-null
consumer to execute and inhibit
errors and exceptions forhandle
- the non-null
consumer to handle any other exceptions
or errors that occurs when calling the consumerE
- if thrown by the handle consumerNullPointerException
- if cmd
or handle
is
null
E extends Throwable
Copyright (C) 2015-2017 The Helenus Driver Project Authors.