Package org.cyclos.server.utils
Class ExceptionHelper
- java.lang.Object
-
- org.cyclos.server.utils.ExceptionHelper
-
public class ExceptionHelper extends Object
Helper methods for exception handling
-
-
Constructor Summary
Constructors Constructor Description ExceptionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Throwable>
TfindCause(Throwable throwable, Class<T> type)Finds an instance of the specified throwable type within the stack trace of the given errorstatic ThrowablefindCause(Throwable throwable, String typeName)Finds an instance of the specified throwable type within the stack trace of the given errorstatic voidthrowUnchecked(Throwable ex)If the givenThrowableis aRuntimeException, throws it as is.static <T extends RuntimeException>
voidthrowWithType(Throwable th, Class<T> type)Throw the specified exception if found in the cause chain from th.
-
-
-
Method Detail
-
findCause
public static <T extends Throwable> T findCause(Throwable throwable, Class<T> type)
Finds an instance of the specified throwable type within the stack trace of the given error
-
findCause
public static Throwable findCause(Throwable throwable, String typeName)
Finds an instance of the specified throwable type within the stack trace of the given error
-
throwUnchecked
public static void throwUnchecked(Throwable ex)
If the givenThrowableis aRuntimeException, throws it as is. Otherwise, throws aRuntimeExceptionwith the given exception as cause
-
throwWithType
public static <T extends RuntimeException> void throwWithType(Throwable th, Class<T> type)
Throw the specified exception if found in the cause chain from th.
-
-