org.springframework.core

Class NestedExceptionUtils

  • java.lang.Object
    • org.springframework.core.NestedExceptionUtils


  • public abstract class NestedExceptionUtils
    extends java.lang.Object
    Helper class for implementing exception classes which are capable of holding nested exceptions. Necessary because we can't share a base class among different exception types.

    Mainly for use within the framework.

    Since:
    2.0
    Author:
    Juergen Hoeller
    See Also:
    NestedRuntimeException, NestedCheckedException, NestedIOException, NestedServletException
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String buildMessage(java.lang.String message, java.lang.Throwable cause)
      Build a message for the given base message and root cause.
      static java.lang.Throwable getMostSpecificCause(java.lang.Throwable original)
      Retrieve the most specific cause of the given exception, that is, either the innermost cause (root cause) or the exception itself.
      static java.lang.Throwable getRootCause(java.lang.Throwable original)
      Retrieve the innermost cause of the given exception, if any.
      • Methods inherited from class java.lang.Object

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

      • NestedExceptionUtils

        public NestedExceptionUtils()
    • Method Detail

      • buildMessage

        @Nullable
        public static java.lang.String buildMessage(@Nullable
                                                              java.lang.String message,
                                                              @Nullable
                                                              java.lang.Throwable cause)
        Build a message for the given base message and root cause.
        Parameters:
        message - the base message
        cause - the root cause
        Returns:
        the full exception message
      • getRootCause

        @Nullable
        public static java.lang.Throwable getRootCause(@Nullable
                                                                 java.lang.Throwable original)
        Retrieve the innermost cause of the given exception, if any.
        Parameters:
        original - the original exception to introspect
        Returns:
        the innermost exception, or null if none
        Since:
        4.3.9
      • getMostSpecificCause

        public static java.lang.Throwable getMostSpecificCause(java.lang.Throwable original)
        Retrieve the most specific cause of the given exception, that is, either the innermost cause (root cause) or the exception itself.

        Differs from getRootCause(java.lang.Throwable) in that it falls back to the original exception if there is no root cause.

        Parameters:
        original - the original exception to introspect
        Returns:
        the most specific cause (never null)
        Since:
        4.3.9