Class ThrowableUtil


  • public final class ThrowableUtil
    extends Object
    A collection of utility functions (static methods) related to Exceptions.
    • Method Detail

      • reason

        public static String reason​(Throwable e)
        Returns the message of specified exception. Returns the class name of specified exception if this exception has no message.
      • detailedReason

        public static String detailedReason​(Throwable e,
                                            int maxCauses)
        Same as reason(java.lang.Throwable) except that the stack trace of specified exception is integrated to returned message.
        Parameters:
        e - the Throwable to be formatted
        maxCauses - in case of a chained Throwable, maximum number of causes (Throwable.getCause()) to be included in the formatted string
        Returns:
        formatted string representation of specified Throwable
      • detailedReason

        public static void detailedReason​(Throwable e,
                                          StringBuilder buffer)
        Copies both the message and the stack trace of specified exception to specified buffer.