Package org.neo4j.gds.utils
Class ExceptionUtil
- java.lang.Object
-
- org.neo4j.gds.utils.ExceptionUtil
-
public final class ExceptionUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static CheckedConsumer<java.lang.Exception,java.lang.Exception>RETHROW_CHECKEDstatic CheckedConsumer<java.lang.Exception,java.lang.RuntimeException>RETHROW_UNCHECKED
-
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 voidcloseAll(java.lang.AutoCloseable... closeables)static voidcloseAll(java.lang.Iterable<? extends java.lang.AutoCloseable> closeables)static voidcloseAll(java.util.Iterator<? extends java.lang.AutoCloseable> closeables)static voidcloseAll(java.util.stream.Stream<? extends java.lang.AutoCloseable> closeables)static <E extends java.lang.Exception>
voidcloseAll(CheckedConsumer<java.lang.Exception,E> handler, java.lang.AutoCloseable... closeables)static <E extends java.lang.Exception>
voidcloseAll(CheckedConsumer<java.lang.Exception,E> handler, java.lang.Iterable<? extends java.lang.AutoCloseable> closeables)static <E extends java.lang.Exception>
voidcloseAll(CheckedConsumer<java.lang.Exception,E> handler, java.util.Iterator<? extends java.lang.AutoCloseable> closeables)static <E extends java.lang.Exception>
voidcloseAll(CheckedConsumer<java.lang.Exception,E> handler, java.util.stream.Stream<? extends java.lang.AutoCloseable> closeables)static <T,E extends java.lang.Exception>
java.util.function.Consumer<T>consumer(CheckedConsumer<T,E> consumer)static <T,R,E extends java.lang.Exception>
java.util.function.Function<T,R>function(CheckedFunction<T,R,E> function)static java.lang.ThrowablerootCause(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 <T,E extends java.lang.Exception>
Tsupply(CheckedSupplier<? extends T,E> supplier)static voidthrowIfUnchecked(java.lang.Throwable exception)Rethrowsexceptionif it is an instance ofRuntimeExceptionorError.static <E extends java.lang.Exception>
java.lang.Runnableunchecked(CheckedRunnable<E> runnable)static voidvalidateSourceNodeIsLoaded(long mappedId, long neoId)static voidvalidateTargetNodeIsLoaded(long mappedId, long neoId)
-
-
-
Field Detail
-
RETHROW_CHECKED
public static final CheckedConsumer<java.lang.Exception,java.lang.Exception> RETHROW_CHECKED
-
RETHROW_UNCHECKED
public static final CheckedConsumer<java.lang.Exception,java.lang.RuntimeException> RETHROW_UNCHECKED
-
-
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
@Contract("null, _ -> param2; !null, _ -> !null") @Nullable public static <T extends java.lang.Throwable> T chain(@Nullable T initial, @Nullable T current)Adds the current exception to the initial exception as suppressed. Copied fromorg.neo4j.helpers.Exceptions#chain(Throwable, Throwable)due to deprecation.
-
closeAll
public static void closeAll(java.util.stream.Stream<? extends java.lang.AutoCloseable> closeables) throws java.lang.Exception- Throws:
java.lang.Exception
-
closeAll
public static void closeAll(java.lang.AutoCloseable... closeables) throws java.lang.Exception- Throws:
java.lang.Exception
-
closeAll
public static void closeAll(java.lang.Iterable<? extends java.lang.AutoCloseable> closeables) throws java.lang.Exception- Throws:
java.lang.Exception
-
closeAll
public static void closeAll(java.util.Iterator<? extends java.lang.AutoCloseable> closeables) throws java.lang.Exception- Throws:
java.lang.Exception
-
closeAll
public static <E extends java.lang.Exception> void closeAll(CheckedConsumer<java.lang.Exception,E> handler, java.util.stream.Stream<? extends java.lang.AutoCloseable> closeables) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
closeAll
public static <E extends java.lang.Exception> void closeAll(CheckedConsumer<java.lang.Exception,E> handler, java.lang.AutoCloseable... closeables) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
closeAll
public static <E extends java.lang.Exception> void closeAll(CheckedConsumer<java.lang.Exception,E> handler, java.lang.Iterable<? extends java.lang.AutoCloseable> closeables) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
closeAll
public static <E extends java.lang.Exception> void closeAll(CheckedConsumer<java.lang.Exception,E> handler, java.util.Iterator<? extends java.lang.AutoCloseable> closeables) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
throwIfUnchecked
public static void throwIfUnchecked(java.lang.Throwable exception)
Rethrowsexceptionif it is an instance ofRuntimeExceptionorError. 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 codeis 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)
-
consumer
public static <T,E extends java.lang.Exception> java.util.function.Consumer<T> consumer(CheckedConsumer<T,E> consumer)
-
function
public static <T,R,E extends java.lang.Exception> java.util.function.Function<T,R> function(CheckedFunction<T,R,E> function)
-
supplier
public static <T,E extends java.lang.Exception> java.util.function.Supplier<? extends T> supplier(CheckedSupplier<? extends T,E> supplier)
-
supply
public static <T,E extends java.lang.Exception> T supply(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)
-
-