- java.lang.Object
-
- com.machinezoo.noexception.ExceptionFilter
-
public abstract class ExceptionFilter extends Object
Represents exception handling policy that always ends with throwing another exception. Methods of this class apply the exception policy to functional interfaces (usually lambdas) by wrapping them in a try-catch block. Methodhandle(Throwable)
defines the exception handling policy when implemented in derived class. See noexception tutorial.Typical usage:
ExceptionLogging.log().passing().get(() -> my_throwing_lambda)
All wrapping methods surround the functional interface with a try-catch block. If the functional interface throws, the exception is caught and passed to
handle(Throwable)
.NullPointerException
fromnull
functional interface is caught too. Methodhandle(Throwable)
applies exception handling policy (log, count, propagate, etc.) and throws a replacement or wrapping exception. If it returns without throwing any exception, the original exception is rethrown.Wrapping methods for all standard functional interfaces are provided. Simple interfaces have short method names like
runnable(Runnable)
orsupplier(Supplier)
. Interfaces with longer names have methods that followfromX
naming pattern, for examplefromUnaryOperator(UnaryOperator)
. Parameterless functional interfaces can be called directly by methodsrun(Runnable)
,get(Supplier)
, and the variousgetAsX
variants.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ExceptionFilter()
Initializes newExceptionFilter
.
-
Method Summary
-
-
-
Method Detail
-
handle
public abstract void handle(Throwable exception)
Handles exception in a generic way. This method must be defined in a derived class. One built-in implementation is provided byExceptionHandler.passing()
. All other methods of theExceptionFilter
call this method, but it can be also called directly.This method represents reusable catch block that handles all exceptions in the same way. When invoked, it must somehow handle the provided exception, for example by logging it. It can also replace or wrap the exception by throwing a new exception. If this method returns without throwing, it is a signal that the original exception should be rethrown. All other methods of this class will rethrow in that case.
- Parameters:
-
exception
- the exception to handle - Throws:
-
NullPointerException
- ifexception
isnull
- See Also:
-
Tutorial,
Exceptions
-
runnable
public final Runnable runnable(Runnable runnable)
Applies exception filter toRunnable
.If
runnable
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
runnable
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingRunnable(ExceptionLogging.log().passing().runnable(() -> my_throwing_lambda))
- Parameters:
-
runnable
- theRunnable
to wrap, usually a lambda - Returns:
-
wrapper that runs
Runnable
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
supplier
public final <T> Supplier<T> supplier(Supplier<T> supplier)
Applies exception filter toSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingSupplier(ExceptionLogging.log().passing().supplier(() -> my_throwing_lambda))
- Type Parameters:
-
T
- seeSupplier
- Parameters:
-
supplier
- theSupplier
to wrap, usually a lambda - Returns:
-
wrapper that runs
Supplier
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntSupplier
public final IntSupplier fromIntSupplier(IntSupplier supplier)
Applies exception filter toIntSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingIntSupplier(ExceptionLogging.log().passing().fromIntSupplier(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theIntSupplier
to wrap, usually a lambda - Returns:
-
wrapper that runs
IntSupplier
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongSupplier
public final LongSupplier fromLongSupplier(LongSupplier supplier)
Applies exception filter toLongSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingLongSupplier(ExceptionLogging.log().passing().fromLongSupplier(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theLongSupplier
to wrap, usually a lambda - Returns:
-
wrapper that runs
LongSupplier
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleSupplier
public final DoubleSupplier fromDoubleSupplier(DoubleSupplier supplier)
Applies exception filter toDoubleSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingDoubleSupplier(ExceptionLogging.log().passing().fromDoubleSupplier(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theDoubleSupplier
to wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleSupplier
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromBooleanSupplier
public final BooleanSupplier fromBooleanSupplier(BooleanSupplier supplier)
Applies exception filter toBooleanSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingBooleanSupplier(ExceptionLogging.log().passing().fromBooleanSupplier(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theBooleanSupplier
to wrap, usually a lambda - Returns:
-
wrapper that runs
BooleanSupplier
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
consumer
public final <T> Consumer<T> consumer(Consumer<T> consumer)
Applies exception filter toConsumer
.If
consumer
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
consumer
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingConsumer(ExceptionLogging.log().passing().consumer(t -> my_throwing_lambda))
- Type Parameters:
-
T
- seeConsumer
- Parameters:
-
consumer
- theConsumer
to wrap, usually a lambda - Returns:
-
wrapper that runs
Consumer
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntConsumer
public final IntConsumer fromIntConsumer(IntConsumer consumer)
Applies exception filter toIntConsumer
.If
consumer
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
consumer
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingIntConsumer(ExceptionLogging.log().passing().fromIntConsumer(v -> my_throwing_lambda))
- Parameters:
-
consumer
- theIntConsumer
to wrap, usually a lambda - Returns:
-
wrapper that runs
IntConsumer
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongConsumer
public final LongConsumer fromLongConsumer(LongConsumer consumer)
Applies exception filter toLongConsumer
.If
consumer
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
consumer
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingLongConsumer(ExceptionLogging.log().passing().fromLongConsumer(v -> my_throwing_lambda))
- Parameters:
-
consumer
- theLongConsumer
to wrap, usually a lambda - Returns:
-
wrapper that runs
LongConsumer
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleConsumer
public final DoubleConsumer fromDoubleConsumer(DoubleConsumer consumer)
Applies exception filter toDoubleConsumer
.If
consumer
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
consumer
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingDoubleConsumer(ExceptionLogging.log().passing().fromDoubleConsumer(v -> my_throwing_lambda))
- Parameters:
-
consumer
- theDoubleConsumer
to wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleConsumer
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromBiConsumer
public final <T,U> BiConsumer<T,U> fromBiConsumer(BiConsumer<T,U> consumer)
Applies exception filter toBiConsumer
.If
consumer
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
consumer
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingBiConsumer(ExceptionLogging.log().passing().fromBiConsumer((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeBiConsumer
-
U
- seeBiConsumer
- Parameters:
-
consumer
- theBiConsumer
to wrap, usually a lambda - Returns:
-
wrapper that runs
BiConsumer
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromObjIntConsumer
public final <T> ObjIntConsumer<T> fromObjIntConsumer(ObjIntConsumer<T> consumer)
Applies exception filter toObjIntConsumer
.If
consumer
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
consumer
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingObjIntConsumer(ExceptionLogging.log().passing().fromObjIntConsumer((t, v) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeObjIntConsumer
- Parameters:
-
consumer
- theObjIntConsumer
to wrap, usually a lambda - Returns:
-
wrapper that runs
ObjIntConsumer
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromObjLongConsumer
public final <T> ObjLongConsumer<T> fromObjLongConsumer(ObjLongConsumer<T> consumer)
Applies exception filter toObjLongConsumer
.If
consumer
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
consumer
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingObjLongConsumer(ExceptionLogging.log().passing().fromObjLongConsumer((t, v) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeObjLongConsumer
- Parameters:
-
consumer
- theObjLongConsumer
to wrap, usually a lambda - Returns:
-
wrapper that runs
ObjLongConsumer
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromObjDoubleConsumer
public final <T> ObjDoubleConsumer<T> fromObjDoubleConsumer(ObjDoubleConsumer<T> consumer)
Applies exception filter toObjDoubleConsumer
.If
consumer
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
consumer
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingObjDoubleConsumer(ExceptionLogging.log().passing().fromObjDoubleConsumer((t, v) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeObjDoubleConsumer
- Parameters:
-
consumer
- theObjDoubleConsumer
to wrap, usually a lambda - Returns:
-
wrapper that runs
ObjDoubleConsumer
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
predicate
public final <T> Predicate<T> predicate(Predicate<T> predicate)
Applies exception filter toPredicate
.If
predicate
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
predicate
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingPredicate(ExceptionLogging.log().passing().predicate(t -> my_throwing_lambda))
- Type Parameters:
-
T
- seePredicate
- Parameters:
-
predicate
- thePredicate
to wrap, usually a lambda - Returns:
-
wrapper that runs
Predicate
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntPredicate
public final IntPredicate fromIntPredicate(IntPredicate predicate)
Applies exception filter toIntPredicate
.If
predicate
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
predicate
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingIntPredicate(ExceptionLogging.log().passing().fromIntPredicate(v -> my_throwing_lambda))
- Parameters:
-
predicate
- theIntPredicate
to wrap, usually a lambda - Returns:
-
wrapper that runs
IntPredicate
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongPredicate
public final LongPredicate fromLongPredicate(LongPredicate predicate)
Applies exception filter toLongPredicate
.If
predicate
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
predicate
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingLongPredicate(ExceptionLogging.log().passing().fromLongPredicate(v -> my_throwing_lambda))
- Parameters:
-
predicate
- theLongPredicate
to wrap, usually a lambda - Returns:
-
wrapper that runs
LongPredicate
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoublePredicate
public final DoublePredicate fromDoublePredicate(DoublePredicate predicate)
Applies exception filter toDoublePredicate
.If
predicate
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
predicate
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingDoublePredicate(ExceptionLogging.log().passing().fromDoublePredicate(v -> my_throwing_lambda))
- Parameters:
-
predicate
- theDoublePredicate
to wrap, usually a lambda - Returns:
-
wrapper that runs
DoublePredicate
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromBiPredicate
public final <T,U> BiPredicate<T,U> fromBiPredicate(BiPredicate<T,U> predicate)
Applies exception filter toBiPredicate
.If
predicate
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
predicate
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingBiPredicate(ExceptionLogging.log().passing().fromBiPredicate((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeBiPredicate
-
U
- seeBiPredicate
- Parameters:
-
predicate
- theBiPredicate
to wrap, usually a lambda - Returns:
-
wrapper that runs
BiPredicate
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
function
public final <T,R> Function<T,R> function(Function<T,R> function)
Applies exception filter toFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingFunction(ExceptionLogging.log().passing().function(t -> my_throwing_lambda))
-
fromToIntFunction
public final <T> ToIntFunction<T> fromToIntFunction(ToIntFunction<T> function)
Applies exception filter toToIntFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingToIntFunction(ExceptionLogging.log().passing().fromToIntFunction(v -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToIntFunction
- Parameters:
-
function
- theToIntFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
ToIntFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntFunction
public final <R> IntFunction<R> fromIntFunction(IntFunction<R> function)
Applies exception filter toIntFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingIntFunction(ExceptionLogging.log().passing().fromIntFunction(v -> my_throwing_lambda))
- Type Parameters:
-
R
- seeIntFunction
- Parameters:
-
function
- theIntFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
IntFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntToLongFunction
public final IntToLongFunction fromIntToLongFunction(IntToLongFunction function)
Applies exception filter toIntToLongFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingIntToLongFunction(ExceptionLogging.log().passing().fromIntToLongFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theIntToLongFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
IntToLongFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntToDoubleFunction
public final IntToDoubleFunction fromIntToDoubleFunction(IntToDoubleFunction function)
Applies exception filter toIntToDoubleFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingIntToDoubleFunction(ExceptionLogging.log().passing().fromIntToDoubleFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theIntToDoubleFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
IntToDoubleFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromToLongFunction
public final <T> ToLongFunction<T> fromToLongFunction(ToLongFunction<T> function)
Applies exception filter toToLongFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingToLongFunction(ExceptionLogging.log().passing().fromToLongFunction(v -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToLongFunction
- Parameters:
-
function
- theToLongFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
ToLongFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongFunction
public final <R> LongFunction<R> fromLongFunction(LongFunction<R> function)
Applies exception filter toLongFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingLongFunction(ExceptionLogging.log().passing().fromLongFunction(v -> my_throwing_lambda))
- Type Parameters:
-
R
- seeLongFunction
- Parameters:
-
function
- theLongFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
LongFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongToIntFunction
public final LongToIntFunction fromLongToIntFunction(LongToIntFunction function)
Applies exception filter toLongToIntFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingLongToIntFunction(ExceptionLogging.log().passing().fromLongToIntFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theLongToIntFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
LongToIntFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongToDoubleFunction
public final LongToDoubleFunction fromLongToDoubleFunction(LongToDoubleFunction function)
Applies exception filter toLongToDoubleFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingLongToDoubleFunction(ExceptionLogging.log().passing().fromLongToDoubleFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theLongToDoubleFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
LongToDoubleFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromToDoubleFunction
public final <T> ToDoubleFunction<T> fromToDoubleFunction(ToDoubleFunction<T> function)
Applies exception filter toToDoubleFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingToDoubleFunction(ExceptionLogging.log().passing().fromToDoubleFunction(v -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToDoubleFunction
- Parameters:
-
function
- theToDoubleFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
ToDoubleFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleFunction
public final <R> DoubleFunction<R> fromDoubleFunction(DoubleFunction<R> function)
Applies exception filter toDoubleFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingDoubleFunction(ExceptionLogging.log().passing().fromDoubleFunction(v -> my_throwing_lambda))
- Type Parameters:
-
R
- seeDoubleFunction
- Parameters:
-
function
- theDoubleFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleToIntFunction
public final DoubleToIntFunction fromDoubleToIntFunction(DoubleToIntFunction function)
Applies exception filter toDoubleToIntFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingDoubleToIntFunction(ExceptionLogging.log().passing().fromDoubleToIntFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theDoubleToIntFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleToIntFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleToLongFunction
public final DoubleToLongFunction fromDoubleToLongFunction(DoubleToLongFunction function)
Applies exception filter toDoubleToLongFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingDoubleToLongFunction(ExceptionLogging.log().passing().fromDoubleToLongFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theDoubleToLongFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleToLongFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromUnaryOperator
public final <T> UnaryOperator<T> fromUnaryOperator(UnaryOperator<T> operator)
Applies exception filter toUnaryOperator
.If
operator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
operator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingUnaryOperator(ExceptionLogging.log().passing().fromUnaryOperator(o -> my_throwing_lambda))
- Type Parameters:
-
T
- seeUnaryOperator
- Parameters:
-
operator
- theUnaryOperator
to wrap, usually a lambda - Returns:
-
wrapper that runs
UnaryOperator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntUnaryOperator
public final IntUnaryOperator fromIntUnaryOperator(IntUnaryOperator operator)
Applies exception filter toIntUnaryOperator
.If
operator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
operator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingIntUnaryOperator(ExceptionLogging.log().passing().fromIntUnaryOperator(o -> my_throwing_lambda))
- Parameters:
-
operator
- theIntUnaryOperator
to wrap, usually a lambda - Returns:
-
wrapper that runs
IntUnaryOperator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongUnaryOperator
public final LongUnaryOperator fromLongUnaryOperator(LongUnaryOperator operator)
Applies exception filter toLongUnaryOperator
.If
operator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
operator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingLongUnaryOperator(ExceptionLogging.log().passing().fromLongUnaryOperator(o -> my_throwing_lambda))
- Parameters:
-
operator
- theLongUnaryOperator
to wrap, usually a lambda - Returns:
-
wrapper that runs
LongUnaryOperator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleUnaryOperator
public final DoubleUnaryOperator fromDoubleUnaryOperator(DoubleUnaryOperator operator)
Applies exception filter toDoubleUnaryOperator
.If
operator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
operator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingDoubleUnaryOperator(ExceptionLogging.log().passing().fromDoubleUnaryOperator(o -> my_throwing_lambda))
- Parameters:
-
operator
- theDoubleUnaryOperator
to wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleUnaryOperator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromBiFunction
public final <T,U,R> BiFunction<T,U,R> fromBiFunction(BiFunction<T,U,R> function)
Applies exception filter toBiFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingBiFunction(ExceptionLogging.log().passing().fromBiFunction((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeBiFunction
-
U
- seeBiFunction
-
R
- seeBiFunction
- Parameters:
-
function
- theBiFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
BiFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromToIntBiFunction
public final <T,U> ToIntBiFunction<T,U> fromToIntBiFunction(ToIntBiFunction<T,U> function)
Applies exception filter toToIntBiFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingToIntBiFunction(ExceptionLogging.log().passing().fromToIntBiFunction((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToIntBiFunction
-
U
- seeToIntBiFunction
- Parameters:
-
function
- theToIntBiFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
ToIntBiFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromToLongBiFunction
public final <T,U> ToLongBiFunction<T,U> fromToLongBiFunction(ToLongBiFunction<T,U> function)
Applies exception filter toToLongBiFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingToLongBiFunction(ExceptionLogging.log().passing().fromToLongBiFunction((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToLongBiFunction
-
U
- seeToLongBiFunction
- Parameters:
-
function
- theToLongBiFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
ToLongBiFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromToDoubleBiFunction
public final <T,U> ToDoubleBiFunction<T,U> fromToDoubleBiFunction(ToDoubleBiFunction<T,U> function)
Applies exception filter toToDoubleBiFunction
.If
function
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
function
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingToDoubleBiFunction(ExceptionLogging.log().passing().fromToDoubleBiFunction((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToDoubleBiFunction
-
U
- seeToDoubleBiFunction
- Parameters:
-
function
- theToDoubleBiFunction
to wrap, usually a lambda - Returns:
-
wrapper that runs
ToDoubleBiFunction
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromBinaryOperator
public final <T> BinaryOperator<T> fromBinaryOperator(BinaryOperator<T> operator)
Applies exception filter toBinaryOperator
.If
operator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
operator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingBinaryOperator(ExceptionLogging.log().passing().fromBinaryOperator((l, r) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeBinaryOperator
- Parameters:
-
operator
- theBinaryOperator
to wrap, usually a lambda - Returns:
-
wrapper that runs
BinaryOperator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntBinaryOperator
public final IntBinaryOperator fromIntBinaryOperator(IntBinaryOperator operator)
Applies exception filter toIntBinaryOperator
.If
operator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
operator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingIntBinaryOperator(ExceptionLogging.log().passing().fromIntBinaryOperator((l, r) -> my_throwing_lambda))
- Parameters:
-
operator
- theIntBinaryOperator
to wrap, usually a lambda - Returns:
-
wrapper that runs
IntBinaryOperator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongBinaryOperator
public final LongBinaryOperator fromLongBinaryOperator(LongBinaryOperator operator)
Applies exception filter toLongBinaryOperator
.If
operator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
operator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingLongBinaryOperator(ExceptionLogging.log().passing().fromLongBinaryOperator((l, r) -> my_throwing_lambda))
- Parameters:
-
operator
- theLongBinaryOperator
to wrap, usually a lambda - Returns:
-
wrapper that runs
LongBinaryOperator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleBinaryOperator
public final DoubleBinaryOperator fromDoubleBinaryOperator(DoubleBinaryOperator operator)
Applies exception filter toDoubleBinaryOperator
.If
operator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
operator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingDoubleBinaryOperator(ExceptionLogging.log().passing().fromDoubleBinaryOperator((l, r) -> my_throwing_lambda))
- Parameters:
-
operator
- theDoubleBinaryOperator
to wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleBinaryOperator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
comparator
public final <T> Comparator<T> comparator(Comparator<T> comparator)
Applies exception filter toComparator
.If
comparator
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
comparator
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
methodTakingComparator(ExceptionLogging.log().passing().comparator((l, r) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeComparator
- Parameters:
-
comparator
- theComparator
to wrap, usually a lambda - Returns:
-
wrapper that runs
Comparator
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
closeable
public final CloseableScope closeable(CloseableScope closeable)
Applies exception filter toCloseableScope
.If
closeable
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
closeable
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
try (var scope = ExceptionLogging.log().passing().closeable(openSomething()))
- Parameters:
-
closeable
- theCloseableScope
to wrap - Returns:
-
wrapper that runs
CloseableScope
in a try-catch block - See Also:
-
Tutorial,
Exceptions
-
run
public final void run(Runnable runnable)
Filters exceptions while runningRunnable
.If
runnable
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
runnable
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
ExceptionLogging.log().passing().run(() -> my_throwing_lambda))
- Parameters:
-
runnable
- theRunnable
to run, usually a lambda - Throws:
-
NullPointerException
- ifrunnable
isnull
- See Also:
-
Tutorial,
Exceptions
-
get
public final <T> T get(Supplier<T> supplier)
Filters exceptions while runningSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
ExceptionLogging.log().passing().get(() -> my_throwing_lambda))
- Type Parameters:
-
T
- seeSupplier
- Parameters:
-
supplier
- theSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
getAsInt
public final int getAsInt(IntSupplier supplier)
Filters exceptions while runningIntSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
ExceptionLogging.log().passing().getAsInt(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theIntSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
getAsLong
public final long getAsLong(LongSupplier supplier)
Filters exceptions while runningLongSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
ExceptionLogging.log().passing().getAsLong(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theLongSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
getAsDouble
public final double getAsDouble(DoubleSupplier supplier)
Filters exceptions while runningDoubleSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
ExceptionLogging.log().passing().getAsDouble(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theDoubleSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
getAsBoolean
public final boolean getAsBoolean(BooleanSupplier supplier)
Filters exceptions while runningBooleanSupplier
.If
supplier
throws an exception, the exception is caught and passed tohandle(Throwable)
.NullPointerException
fromnull
supplier
is caught too. Methodhandle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.Typical usage:
ExceptionLogging.log().passing().getAsBoolean(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theBooleanSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
-