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 extends java.lang.Throwable>
Tchain(T initial, T current)
Adds the current exception to the initial exception as suppressed.static java.lang.Throwable
rootCause(java.lang.Throwable caughtException)
Returns the root cause of an exception.static void
throwIfUnchecked(java.lang.Throwable exception)
Rethrowsexception
if it is an instance ofRuntimeException
orError
.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.
-
validateTargetNodeIsLoaded
public static void validateTargetNodeIsLoaded(long mappedId, long neoId)
-
validateSourceNodeIsLoaded
public static void validateSourceNodeIsLoaded(long mappedId, long neoId)
-
-