Package com.norconex.commons.lang

# Class ExceptionUtil

java.lang.Object
com.norconex.commons.lang.ExceptionUtil

public final class ExceptionUtil extends Object
Exception-related utility methods.

Since:
  2.0.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `ExceptionUtil.ExceptionMessage`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static List<ExceptionUtil.ExceptionMessage>`
  `getExceptionMessageList(Throwable throwable)`
  Gets a list made of all exceptions classes and their message found in an exception stack, starting with the supplied exception itself.
  `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.
  `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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### 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`

  - ### getExceptionMessageList

    public static List<ExceptionUtil.ExceptionMessage> getExceptionMessageList(Throwable throwable)

    Gets a list made of all exceptions classes and their message found in an exception stack, starting with the supplied exception itself.

    Exceptions without a message will result in a `null` map value.

    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`