- 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).NullPointerExceptionfromnullfunctional 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 followfromXnaming pattern, for examplefromUnaryOperator(UnaryOperator). Parameterless functional interfaces can be called directly by methodsrun(Runnable),get(Supplier), and the variousgetAsXvariants.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedExceptionFilter()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 theExceptionFiltercall 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- ifexceptionisnull - See Also:
-
Tutorial,
Exceptions
-
runnable
public final Runnable runnable(Runnable runnable)
Applies exception filter toRunnable.If
runnablethrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullrunnableis 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- theRunnableto wrap, usually a lambda - Returns:
-
wrapper that runs
Runnablein a try-catch block - See Also:
-
Tutorial,
Exceptions
-
supplier
public final <T> Supplier<T> supplier(Supplier<T> supplier)
Applies exception filter toSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theSupplierto wrap, usually a lambda - Returns:
-
wrapper that runs
Supplierin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntSupplier
public final IntSupplier fromIntSupplier(IntSupplier supplier)
Applies exception filter toIntSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theIntSupplierto wrap, usually a lambda - Returns:
-
wrapper that runs
IntSupplierin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongSupplier
public final LongSupplier fromLongSupplier(LongSupplier supplier)
Applies exception filter toLongSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theLongSupplierto wrap, usually a lambda - Returns:
-
wrapper that runs
LongSupplierin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleSupplier
public final DoubleSupplier fromDoubleSupplier(DoubleSupplier supplier)
Applies exception filter toDoubleSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theDoubleSupplierto wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleSupplierin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromBooleanSupplier
public final BooleanSupplier fromBooleanSupplier(BooleanSupplier supplier)
Applies exception filter toBooleanSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theBooleanSupplierto wrap, usually a lambda - Returns:
-
wrapper that runs
BooleanSupplierin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
consumer
public final <T> Consumer<T> consumer(Consumer<T> consumer)
Applies exception filter toConsumer.If
consumerthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullconsumeris 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- theConsumerto wrap, usually a lambda - Returns:
-
wrapper that runs
Consumerin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntConsumer
public final IntConsumer fromIntConsumer(IntConsumer consumer)
Applies exception filter toIntConsumer.If
consumerthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullconsumeris 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- theIntConsumerto wrap, usually a lambda - Returns:
-
wrapper that runs
IntConsumerin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongConsumer
public final LongConsumer fromLongConsumer(LongConsumer consumer)
Applies exception filter toLongConsumer.If
consumerthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullconsumeris 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- theLongConsumerto wrap, usually a lambda - Returns:
-
wrapper that runs
LongConsumerin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleConsumer
public final DoubleConsumer fromDoubleConsumer(DoubleConsumer consumer)
Applies exception filter toDoubleConsumer.If
consumerthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullconsumeris 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- theDoubleConsumerto wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleConsumerin 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
consumerthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullconsumeris 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- theBiConsumerto wrap, usually a lambda - Returns:
-
wrapper that runs
BiConsumerin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromObjIntConsumer
public final <T> ObjIntConsumer<T> fromObjIntConsumer(ObjIntConsumer<T> consumer)
Applies exception filter toObjIntConsumer.If
consumerthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullconsumeris 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- theObjIntConsumerto wrap, usually a lambda - Returns:
-
wrapper that runs
ObjIntConsumerin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromObjLongConsumer
public final <T> ObjLongConsumer<T> fromObjLongConsumer(ObjLongConsumer<T> consumer)
Applies exception filter toObjLongConsumer.If
consumerthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullconsumeris 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- theObjLongConsumerto wrap, usually a lambda - Returns:
-
wrapper that runs
ObjLongConsumerin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromObjDoubleConsumer
public final <T> ObjDoubleConsumer<T> fromObjDoubleConsumer(ObjDoubleConsumer<T> consumer)
Applies exception filter toObjDoubleConsumer.If
consumerthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullconsumeris 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- theObjDoubleConsumerto wrap, usually a lambda - Returns:
-
wrapper that runs
ObjDoubleConsumerin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
predicate
public final <T> Predicate<T> predicate(Predicate<T> predicate)
Applies exception filter toPredicate.If
predicatethrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullpredicateis 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- thePredicateto wrap, usually a lambda - Returns:
-
wrapper that runs
Predicatein a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntPredicate
public final IntPredicate fromIntPredicate(IntPredicate predicate)
Applies exception filter toIntPredicate.If
predicatethrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullpredicateis 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- theIntPredicateto wrap, usually a lambda - Returns:
-
wrapper that runs
IntPredicatein a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongPredicate
public final LongPredicate fromLongPredicate(LongPredicate predicate)
Applies exception filter toLongPredicate.If
predicatethrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullpredicateis 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- theLongPredicateto wrap, usually a lambda - Returns:
-
wrapper that runs
LongPredicatein a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoublePredicate
public final DoublePredicate fromDoublePredicate(DoublePredicate predicate)
Applies exception filter toDoublePredicate.If
predicatethrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullpredicateis 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- theDoublePredicateto wrap, usually a lambda - Returns:
-
wrapper that runs
DoublePredicatein 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
predicatethrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullpredicateis 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- theBiPredicateto wrap, usually a lambda - Returns:
-
wrapper that runs
BiPredicatein 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
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theToIntFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
ToIntFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntFunction
public final <R> IntFunction<R> fromIntFunction(IntFunction<R> function)
Applies exception filter toIntFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theIntFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
IntFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntToLongFunction
public final IntToLongFunction fromIntToLongFunction(IntToLongFunction function)
Applies exception filter toIntToLongFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theIntToLongFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
IntToLongFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntToDoubleFunction
public final IntToDoubleFunction fromIntToDoubleFunction(IntToDoubleFunction function)
Applies exception filter toIntToDoubleFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theIntToDoubleFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
IntToDoubleFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromToLongFunction
public final <T> ToLongFunction<T> fromToLongFunction(ToLongFunction<T> function)
Applies exception filter toToLongFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theToLongFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
ToLongFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongFunction
public final <R> LongFunction<R> fromLongFunction(LongFunction<R> function)
Applies exception filter toLongFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theLongFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
LongFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongToIntFunction
public final LongToIntFunction fromLongToIntFunction(LongToIntFunction function)
Applies exception filter toLongToIntFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theLongToIntFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
LongToIntFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongToDoubleFunction
public final LongToDoubleFunction fromLongToDoubleFunction(LongToDoubleFunction function)
Applies exception filter toLongToDoubleFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theLongToDoubleFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
LongToDoubleFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromToDoubleFunction
public final <T> ToDoubleFunction<T> fromToDoubleFunction(ToDoubleFunction<T> function)
Applies exception filter toToDoubleFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theToDoubleFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
ToDoubleFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleFunction
public final <R> DoubleFunction<R> fromDoubleFunction(DoubleFunction<R> function)
Applies exception filter toDoubleFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theDoubleFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleToIntFunction
public final DoubleToIntFunction fromDoubleToIntFunction(DoubleToIntFunction function)
Applies exception filter toDoubleToIntFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theDoubleToIntFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleToIntFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleToLongFunction
public final DoubleToLongFunction fromDoubleToLongFunction(DoubleToLongFunction function)
Applies exception filter toDoubleToLongFunction.If
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theDoubleToLongFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleToLongFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromUnaryOperator
public final <T> UnaryOperator<T> fromUnaryOperator(UnaryOperator<T> operator)
Applies exception filter toUnaryOperator.If
operatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnulloperatoris 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- theUnaryOperatorto wrap, usually a lambda - Returns:
-
wrapper that runs
UnaryOperatorin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntUnaryOperator
public final IntUnaryOperator fromIntUnaryOperator(IntUnaryOperator operator)
Applies exception filter toIntUnaryOperator.If
operatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnulloperatoris 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- theIntUnaryOperatorto wrap, usually a lambda - Returns:
-
wrapper that runs
IntUnaryOperatorin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongUnaryOperator
public final LongUnaryOperator fromLongUnaryOperator(LongUnaryOperator operator)
Applies exception filter toLongUnaryOperator.If
operatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnulloperatoris 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- theLongUnaryOperatorto wrap, usually a lambda - Returns:
-
wrapper that runs
LongUnaryOperatorin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleUnaryOperator
public final DoubleUnaryOperator fromDoubleUnaryOperator(DoubleUnaryOperator operator)
Applies exception filter toDoubleUnaryOperator.If
operatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnulloperatoris 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- theDoubleUnaryOperatorto wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleUnaryOperatorin 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
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theBiFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
BiFunctionin 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
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theToIntBiFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
ToIntBiFunctionin 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
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theToLongBiFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
ToLongBiFunctionin 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
functionthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullfunctionis 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- theToDoubleBiFunctionto wrap, usually a lambda - Returns:
-
wrapper that runs
ToDoubleBiFunctionin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromBinaryOperator
public final <T> BinaryOperator<T> fromBinaryOperator(BinaryOperator<T> operator)
Applies exception filter toBinaryOperator.If
operatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnulloperatoris 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- theBinaryOperatorto wrap, usually a lambda - Returns:
-
wrapper that runs
BinaryOperatorin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromIntBinaryOperator
public final IntBinaryOperator fromIntBinaryOperator(IntBinaryOperator operator)
Applies exception filter toIntBinaryOperator.If
operatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnulloperatoris 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- theIntBinaryOperatorto wrap, usually a lambda - Returns:
-
wrapper that runs
IntBinaryOperatorin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromLongBinaryOperator
public final LongBinaryOperator fromLongBinaryOperator(LongBinaryOperator operator)
Applies exception filter toLongBinaryOperator.If
operatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnulloperatoris 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- theLongBinaryOperatorto wrap, usually a lambda - Returns:
-
wrapper that runs
LongBinaryOperatorin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
fromDoubleBinaryOperator
public final DoubleBinaryOperator fromDoubleBinaryOperator(DoubleBinaryOperator operator)
Applies exception filter toDoubleBinaryOperator.If
operatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnulloperatoris 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- theDoubleBinaryOperatorto wrap, usually a lambda - Returns:
-
wrapper that runs
DoubleBinaryOperatorin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
comparator
public final <T> Comparator<T> comparator(Comparator<T> comparator)
Applies exception filter toComparator.If
comparatorthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullcomparatoris 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- theComparatorto wrap, usually a lambda - Returns:
-
wrapper that runs
Comparatorin a try-catch block - See Also:
-
Tutorial,
Exceptions
-
closeable
public final CloseableScope closeable(CloseableScope closeable)
Applies exception filter toCloseableScope.If
closeablethrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullcloseableis 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- theCloseableScopeto wrap - Returns:
-
wrapper that runs
CloseableScopein a try-catch block - See Also:
-
Tutorial,
Exceptions
-
run
public final void run(Runnable runnable)
Filters exceptions while runningRunnable.If
runnablethrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullrunnableis 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- theRunnableto run, usually a lambda - Throws:
-
NullPointerException- ifrunnableisnull - See Also:
-
Tutorial,
Exceptions
-
get
public final <T> T get(Supplier<T> supplier)
Filters exceptions while runningSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
getAsInt
public final int getAsInt(IntSupplier supplier)
Filters exceptions while runningIntSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theIntSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
getAsLong
public final long getAsLong(LongSupplier supplier)
Filters exceptions while runningLongSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theLongSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
getAsDouble
public final double getAsDouble(DoubleSupplier supplier)
Filters exceptions while runningDoubleSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theDoubleSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
getAsBoolean
public final boolean getAsBoolean(BooleanSupplier supplier)
Filters exceptions while runningBooleanSupplier.If
supplierthrows an exception, the exception is caught and passed tohandle(Throwable).NullPointerExceptionfromnullsupplieris 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- theBooleanSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
-