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,​R,​E extends java.lang.Exception>
      R
      apply​(CheckedFunction<? super T,​? extends R,​E> function, T input)  
      static <T extends java.lang.Throwable>
      T
      chain​(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<T,​R>
      function​(CheckedFunction<T,​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>
      void
      run​(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>
      T
      supply​(CheckedSupplier<? extends T,​E> supplier)  
      static void throwIfUnchecked​(java.lang.Throwable exception)
      Rethrows exception if it is an instance of RuntimeException or Error.
      static <E extends java.lang.Exception>
      java.lang.Runnable
      unchecked​(CheckedRunnable<E> runnable)  
      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.
      • 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<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)