org.carrot2.util
Class ExceptionUtils

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

public final class ExceptionUtils
extends Object

A number of utility classes for working with Throwables.


Method Summary
static String currentStackTrace()
          Returns the current stack trace of the calling thread.
static
<T extends Throwable>
T
wrapAs(Class<T> clazz, Throwable t)
          If t if an instance of clazz, then t is returned.
static RuntimeException wrapAsRuntimeException(Throwable t)
          Calls wrapAs(Class, Throwable) with the first parameter set to RuntimeException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.

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.



Copyright (c) Dawid Weiss, Stanislaw Osinski