Class 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>
      T
      chain​(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)
      Rethrows exception if it is an instance of RuntimeException or Error.
      static void validateSourceNodeIsLoaded​(long mappedId, long neoId)  
      static void validateTargetNodeIsLoaded​(long mappedId, long neoId)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • rootCause

        public static java.lang.Throwable rootCause​(java.lang.Throwable caughtException)
        Returns the root cause of an exception. Copied from org.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 from org.neo4j.helpers.Exceptions#chain(Throwable, Throwable) due to deprecation.
      • throwIfUnchecked

        public static void throwIfUnchecked​(java.lang.Throwable exception)
        Rethrows exception if it is an instance of RuntimeException or Error. Typical usage is:
         catch (Throwable e) {
           ......common code......
           throwIfUnchecked(e);
           throw new RuntimeException(e);
         }
         
        This will only wrap checked exception in a RuntimeException. Do note that if the segment common 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)