Class ExceptionUtils

java.lang.Object
org.carrot2.util.ExceptionUtils

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

    • 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.
    • wrapAsRuntimeException

      public static RuntimeException wrapAsRuntimeException(Throwable t)
      Calls wrapAs(Class, Throwable) with the first parameter set to RuntimeException.
    • currentStackTrace

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