Class UncheckedException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    BeanException, TypeConversionException

    public class UncheckedException
    extends java.lang.RuntimeException
    Unchecked exception and also a wrapper for checked exceptions.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Throwable cause  
      protected static java.lang.String CAUSE_DIV
      Divider between causes printouts.
      protected boolean showCauseDetails
      If set to true stack trace will be enhanced with cause's stack traces.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <V> V callAndWrapException​(java.util.concurrent.Callable<V> callable)
      Wraps checked exceptions in a UncheckedException.
      java.lang.Throwable getCause()
      Returns exception cause.
      java.lang.String getMessage()
      Returns the detail message, including the message from the nested exception if there is one.
      void printStackTrace()  
      void printStackTrace​(java.io.PrintStream ps)  
      void printStackTrace​(java.io.PrintWriter pw)  
      void rethrow()
      Re-throws cause if exists.
      static void runAndWrapException​(UncheckedException.CallableVoid callable)
      Wraps checked exceptions in a UncheckedException.
      static java.lang.RuntimeException wrap​(java.lang.Throwable t)
      Wraps all exceptions in a UncheckedException
      static java.lang.RuntimeException wrap​(java.lang.Throwable t, java.lang.String message)
      Wraps all exceptions in a UncheckedException
      • Methods inherited from class java.lang.Throwable

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

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

      • cause

        protected final java.lang.Throwable cause
      • CAUSE_DIV

        protected static final java.lang.String CAUSE_DIV
        Divider between causes printouts.
        See Also:
        Constant Field Values
      • showCauseDetails

        protected final boolean showCauseDetails
        If set to true stack trace will be enhanced with cause's stack traces.
    • Constructor Detail

      • UncheckedException

        public UncheckedException​(java.lang.Throwable t)
      • UncheckedException

        public UncheckedException​(java.lang.Throwable t,
                                  boolean showCauseDetails)
      • UncheckedException

        public UncheckedException()
      • UncheckedException

        public UncheckedException​(java.lang.String message)
      • UncheckedException

        public UncheckedException​(java.lang.String message,
                                  java.lang.Throwable t)
      • UncheckedException

        public UncheckedException​(java.lang.String message,
                                  java.lang.Throwable t,
                                  boolean showCauseDetails)
    • Method Detail

      • printStackTrace

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

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

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

        public java.lang.String getMessage()
        Returns the detail message, including the message from the nested exception if there is one.
        Overrides:
        getMessage in class java.lang.Throwable
      • callAndWrapException

        public static <V> V callAndWrapException​(java.util.concurrent.Callable<V> callable)
        Wraps checked exceptions in a UncheckedException. Unchecked exceptions are not wrapped.
      • runAndWrapException

        public static void runAndWrapException​(UncheckedException.CallableVoid callable)
        Wraps checked exceptions in a UncheckedException. Unchecked exceptions are not wrapped.
      • wrap

        public static java.lang.RuntimeException wrap​(java.lang.Throwable t)
        Wraps all exceptions in a UncheckedException
      • wrap

        public static java.lang.RuntimeException wrap​(java.lang.Throwable t,
                                                      java.lang.String message)
        Wraps all exceptions in a UncheckedException
      • rethrow

        public void rethrow()
                     throws java.lang.Throwable
        Re-throws cause if exists.
        Throws:
        java.lang.Throwable
      • getCause

        public java.lang.Throwable getCause()
        Returns exception cause.
        Overrides:
        getCause in class java.lang.Throwable