Class CheckedExceptionTunnel

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getMessage()  
      void printFullStackTrace()
      Like Throwable.printStackTrace(), but includes the tunnel's stacktrace as well.
      void printFullStackTrace​(java.io.PrintStream s)
      Like printStackTrace(PrintStream), but includes the tunnel's stacktrace as well.
      void printFullStackTrace​(java.io.PrintWriter s)
      Like printStackTrace(PrintWriter), but includes the tunnel's stacktrace as well.
      void printStackTrace​(java.io.PrintStream s)  
      void printStackTrace​(java.io.PrintWriter s)  
      java.lang.String toString()  
      static java.lang.Exception unwrapIfNecessary​(java.lang.Exception exception)
      Returns the original exception before being wrapped, if the exception has been wrapped, or exception otherwise.
      static java.lang.Throwable unwrapIfNecessary​(java.lang.Throwable throwable)
      Returns the original throwable before being wrapped, if the throwable has been wrapped, or exception otherwise.
      static java.lang.RuntimeException wrapIfNecessary​(java.lang.Exception exception)
      Returns a RuntimeException from an exception.
      static java.lang.RuntimeException wrapIfNecessary​(java.lang.Throwable throwable)
      Convenience wrapper for wrapIfNecessary(Exception).
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CheckedExceptionTunnel

        public CheckedExceptionTunnel​(java.lang.Exception checkedExceptionOrNull)
        Returns an unchecked exception from a checkedException.
        Parameters:
        checkedExceptionOrNull - The checked exception to tunnel.
      • CheckedExceptionTunnel

        protected CheckedExceptionTunnel​(java.lang.String msg)
      • CheckedExceptionTunnel

        protected CheckedExceptionTunnel()
    • Method Detail

      • getMessage

        public java.lang.String getMessage()
        Overrides:
        getMessage in class java.lang.Throwable
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Throwable
      • printStackTrace

        public void printStackTrace​(java.io.PrintStream s)
        Overrides:
        printStackTrace in class java.lang.Throwable
      • printStackTrace

        public void printStackTrace​(java.io.PrintWriter s)
        Overrides:
        printStackTrace in class java.lang.Throwable
      • printFullStackTrace

        public void printFullStackTrace()
        Like Throwable.printStackTrace(), but includes the tunnel's stacktrace as well.
      • printFullStackTrace

        public void printFullStackTrace​(java.io.PrintStream s)
        Like printStackTrace(PrintStream), but includes the tunnel's stacktrace as well.
      • printFullStackTrace

        public void printFullStackTrace​(java.io.PrintWriter s)
        Like printStackTrace(PrintWriter), but includes the tunnel's stacktrace as well.
      • wrapIfNecessary

        public static final java.lang.RuntimeException wrapIfNecessary​(java.lang.Throwable throwable)
                                                                throws java.lang.Error
        Convenience wrapper for wrapIfNecessary(Exception). If throwable is an Error, this method will not return but the error will be thrown.
        Parameters:
        throwable - The exception to represent by the return value.
        Returns:
        A RuntimeException representing the throwable.
        Throws:
        java.lang.Error - If throwable is an Error (except when it is a ThreadDeath, which returns a InterruptedExceptionUnchecked).
      • wrapIfNecessary

        public static final java.lang.RuntimeException wrapIfNecessary​(java.lang.Exception exception)
        Returns a RuntimeException from an exception. If exception is already a RuntimeException, itself is returned, otherwise an appropriate unchecked equivalent. If no unchecked equivalent exists, a CheckedExceptionTunnel is returned with exception as checked exception argument.
        Parameters:
        exception - The exception to represent by the return value.
        Returns:
        A RuntimeException representing the exception.
      • unwrapIfNecessary

        public static final java.lang.Exception unwrapIfNecessary​(java.lang.Exception exception)
        Returns the original exception before being wrapped, if the exception has been wrapped, or exception otherwise.
      • unwrapIfNecessary

        public static final java.lang.Throwable unwrapIfNecessary​(java.lang.Throwable throwable)
        Returns the original throwable before being wrapped, if the throwable has been wrapped, or exception otherwise.