public final class ExceptionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
doThrow(Throwable e)
Throws the given throwable even if it is a checked exception.
|
static Throwable |
getCause(Throwable e,
Class<? extends Throwable>... causes)
Gets the cause which are one of the given expected causes.
|
static Throwable |
unwrap(Throwable t,
Class<? extends Throwable>... throwableClasses)
Unwraps the throwable until it is no instance of the throwableClass.
|
static Throwable |
unwrap(Throwable t,
Class<? extends Throwable> throwableClass) |
public static void doThrow(Throwable e)
e - The throwable to throw.@SafeVarargs public static Throwable unwrap(Throwable t, Class<? extends Throwable>... throwableClasses)
Be carefull when you use this method with a too general throwableClass. It might be, that getCause() returns the this element in some cases and this could lead to an endless loop!
t - The throwable to unwrapthrowableClass - The class of which a throwable must be to be
unwrappedpublic static Throwable getCause(Throwable e, Class<? extends Throwable>... causes)
e - the exception instance to search the cause oncauses - the causes which are searched.Copyright © 2020 Blazebit. All rights reserved.