Package org.neo4j.graphalgo.utils
Class ExceptionUtil
- java.lang.Object
-
- org.neo4j.graphalgo.utils.ExceptionUtil
-
public final class ExceptionUtil extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,R,E extends java.lang.Exception>
Rapply(CheckedFunction<? super T,? extends R,E> function, T input)
static <T extends java.lang.Throwable>
Tchain(T initial, T current)
Adds the current exception to the initial exception as suppressed.static <T,R,E extends java.lang.Exception>
java.util.function.Function<? super T,? extends R>function(CheckedFunction<? super T,? extends R,E> function)
static java.lang.Throwable
rootCause(java.lang.Throwable caughtException)
Returns the root cause of an exception.static <E extends java.lang.Exception>
voidrun(CheckedRunnable<E> runnable)
static <T,E extends java.lang.Exception>
java.util.function.Supplier<? extends T>supplier(CheckedSupplier<? extends T,E> supplier)
static void
throwIfUnchecked(java.lang.Throwable exception)
Rethrowsexception
if it is an instance ofRuntimeException
orError
.static <E extends java.lang.Exception>
java.lang.Runnableunchecked(CheckedRunnable<E> runnable)
static void
validateSourceNodeIsLoaded(long mappedId, long neoId)
static void
validateTargetNodeIsLoaded(long mappedId, long neoId)
-
-
-
Method Detail
-
rootCause
public static java.lang.Throwable rootCause(java.lang.Throwable caughtException)
Returns the root cause of an exception. Copied fromorg.neo4j.helpers.Exceptions#rootCause(Throwable)
due to deprecation.- Parameters:
caughtException
- exception to find the root cause of.- Returns:
- the root cause.
- Throws:
java.lang.IllegalArgumentException
- if the provided exception is null.
-
chain
public static <T extends java.lang.Throwable> T chain(T initial, T current)
Adds the current exception to the initial exception as suppressed. Copied fromorg.neo4j.helpers.Exceptions#chain(Throwable, Throwable)
due to deprecation.
-
throwIfUnchecked
public static void throwIfUnchecked(java.lang.Throwable exception)
Rethrowsexception
if it is an instance ofRuntimeException
orError
. Typical usage is:catch (Throwable e) { ......common code...... throwIfUnchecked(e); throw new RuntimeException(e); }
This will only wrap checked exception in aRuntimeException
. Do note that if the segmentcommon code
is missing, it's preferable to use this instead:catch (RuntimeException | Error e) { throw e; } catch (Throwable e) { throw new RuntimeException(e); }
- Parameters:
exception
- to rethrow.
-
unchecked
public static <E extends java.lang.Exception> java.lang.Runnable unchecked(CheckedRunnable<E> runnable)
-
run
public static <E extends java.lang.Exception> void run(CheckedRunnable<E> runnable)
-
function
public static <T,R,E extends java.lang.Exception> java.util.function.Function<? super T,? extends R> function(CheckedFunction<? super T,? extends R,E> function) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
supplier
public static <T,E extends java.lang.Exception> java.util.function.Supplier<? extends T> supplier(CheckedSupplier<? extends T,E> supplier)
-
apply
public static <T,R,E extends java.lang.Exception> R apply(CheckedFunction<? super T,? extends R,E> function, T input)
-
validateTargetNodeIsLoaded
public static void validateTargetNodeIsLoaded(long mappedId, long neoId)
-
validateSourceNodeIsLoaded
public static void validateSourceNodeIsLoaded(long mappedId, long neoId)
-
-