Class UncheckedException

    • Method Detail

      • withStackTrace

        public static UncheckedException withStackTrace​(Throwable cause)
        Creates a new exception with a stack trace of its own.
        Parameters:
        cause - The throwable to wrap.
        Returns:
        The created exception.
        Throws:
        NullPointerException - If the given throwable is null.
      • withStackTrace

        public static UncheckedException withStackTrace​(String message,
                                                        Throwable cause)
        Creates a new exception with a stack trace of its own.
        Parameters:
        message - The optional detail message.
        cause - The throwable to wrap.
        Returns:
        The created exception.
        Throws:
        NullPointerException - If the given throwable is null.
      • withoutStackTrace

        public static UncheckedException withoutStackTrace​(Throwable cause)
        Creates a new exception without a stack trace of its own. This makes the created exception more lightweight.
        Parameters:
        cause - The throwable to wrap.
        Returns:
        The created exception.
        Throws:
        NullPointerException - If the given throwable is null.
      • withoutStackTrace

        public static UncheckedException withoutStackTrace​(String message,
                                                           Throwable cause)
        Creates a new exception with a stack trace of its own. This makes the created exception more lightweight.
        Parameters:
        message - The optional detail message.
        cause - The throwable to wrap.
        Returns:
        The created exception.
        Throws:
        NullPointerException - If the given throwable is null.
      • throwCauseAs

        public <T,​X extends Throwable> T throwCauseAs​(Class<X> errorType)
                                                     throws X extends Throwable
        Throws the wrapped throwable as an instance of a specific error type.
        Type Parameters:
        T - The return type. This allows this method to be used with return statements.
        X - The type of error to throw.
        Parameters:
        errorType - The type of error to throw.
        Returns:
        Nothing. This method always thrown an exception.
        Throws:
        NullPointerException - If the given error type is null.
        X - The wrapped throwable cast to an instance of the given error type.
        IllegalStateException - If the wrapped throwable is not an instance of the given error type.
        X extends Throwable
      • throwCauseAsOneOf

        public <T,​X1 extends Throwable,​X2 extends Throwable> T throwCauseAsOneOf​(Class<X1> errorType1,
                                                                                             Class<X2> errorType2)
                                                                                      throws X1 extends Throwable,
                                                                                             X2 extends Throwable
        Throws the wrapped throwable as an instance of one of a set of specific error types.
        Type Parameters:
        T - The return type. This allows this method to be used with return statements.
        X1 - The type of the first possible error to throw.
        X2 - The type of the second possible error to throw.
        Parameters:
        errorType1 - The type of the first possible error to throw.
        errorType2 - The type of the second possible error to throw.
        Returns:
        Nothing. This method always thrown an exception.
        Throws:
        NullPointerException - If either given error type is null.
        X1 - The wrapped throwable cast to an instance of the first given error type.
        X2 - The wrapped throwable cast to an instance of the second given error type.
        IllegalStateException - If the wrapped throwable is not an instance of either given error type.
        X1 extends Throwable
      • throwCauseAsOneOf

        public <T,​X1 extends Throwable,​X2 extends Throwable,​X3 extends Throwable> T throwCauseAsOneOf​(Class<X1> errorType1,
                                                                                                                        Class<X2> errorType2,
                                                                                                                        Class<X3> errorType3)
                                                                                                                 throws X1 extends Throwable,
                                                                                                                        X2 extends Throwable,
                                                                                                                        X3 extends Throwable
        Throws the wrapped throwable as an instance of one of a set of specific error types.
        Type Parameters:
        T - The return type. This allows this method to be used with return statements.
        X1 - The type of the first possible error to throw.
        X2 - The type of the second possible error to throw.
        X3 - The type of the third possible error to throw.
        Parameters:
        errorType1 - The type of the first possible error to throw.
        errorType2 - The type of the second possible error to throw.
        errorType3 - The type of the third possible error to throw.
        Returns:
        Nothing. This method always thrown an exception.
        Throws:
        NullPointerException - If any given error type is null.
        X1 - The wrapped throwable cast to an instance of the first given error type.
        X2 - The wrapped throwable cast to an instance of the second given error type.
        X3 - The wrapped throwable cast to an instance of the third given error type.
        IllegalStateException - If the wrapped throwable is not an instance of any given error type.
        X1 extends Throwable