Class ExceptionUtil


  • public final class ExceptionUtil
    extends Object
    Exception-related utility methods.
    Since:
    2.0.0
    Author:
    Pascal Essiembre
    • Method Detail

      • getFormattedMessages

        public static String getFormattedMessages​(Throwable throwable)

        Gets a formatted string made of short messages summarizing all exceptions objects in the exception chain, starting with and including the supplied exception.

        Each messages returned are in the form {ClassNameWithoutPackage}: {ThrowableMessage}. Exceptions with null messages are returned as empty strings.

        This method handles infinite loops. A null exception returns an empty string (never null).

        Parameters:
        throwable - the throwable to inspect, may be null
        Returns:
        formatted string or empty string, never null
      • getMessageList

        public static List<String> getMessageList​(Throwable throwable)

        Gets a list of short messages summarizing all exceptions objects in the exception chain, starting with and including the supplied exception.

        Each messages returned are in the form {ClassNameWithoutPackage}: {ThrowableMessage}. Exceptions with null messages are returned as empty strings.

        This method handles infinite loops and never returns null.

        Parameters:
        throwable - the throwable to inspect, may be null
        Returns:
        the list of messages, never null