Class ExceptionUtils


  • public final class ExceptionUtils
    extends Object
    A number of utility classes for working with Throwables.
    • Method Detail

      • wrapAs

        public static <T extends Throwable> T wrapAs​(Class<T> clazz,
                                                     Throwable t)
        If t if an instance of clazz, then t is returned. Otherwise an instance of clazz is created using a single-parameter constructor accepting t and the wrapper exception instance is returned. If no matching constructor can be found, a RuntimeException is returned.
        Parameters:
        clazz - The exception class to return (or wrap) t.
        t - Throwable instance to wrap.
      • currentStackTrace

        public static String currentStackTrace()
        Returns the current stack trace of the calling thread.