Class Exceptions


  • public final class Exceptions
    extends Object
    • Constructor Detail

      • Exceptions

        public Exceptions()
    • Method Detail

      • sneakyThrow

        public static <T extends Throwable,​R> R sneakyThrow​(Throwable t)
                                                           throws T extends Throwable
        Allows us to sneaky throw a checked exception without having to wrap it
        Use with caution
        Throws:
        T extends Throwable
      • getStackTrace

        public static String getStackTrace​(Throwable throwable)
        Get the stacktrace of the throwable as a String
        Parameters:
        throwable - the exception
        Returns:
        the throwable's full stacktrace
      • getRootCause

        public static Throwable getRootCause​(Throwable exception)
        Get the root cause (top most parent) of an Exception.
        Parameters:
        exception - the exception we want the root cause of
        Returns:
        the root cause of the exception - will never be null