Class Exceptions
java.lang.Object
dev.derklaro.reflexion.internal.util.Exceptions
A utility to improve working with exceptions thrown during the program runtime.
- Since:
- 1.8.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanGet if the given exception is an unrecoverable error which prevents the program to resume (on the current thread).static voidrethrowIfFatal(@NotNull Throwable throwable) Rethrows the given exception if it signals an unrecoverable error which prevents the program to resume (on the current thread).static <T extends Throwable>
voidthrowUnchecked(@NotNull Throwable throwable) Throws the given exception as an unchecked exception removing the need to catch non-runtime exceptions.
-
Constructor Details
-
Exceptions
private Exceptions()
-
-
Method Details
-
throwUnchecked
public static <T extends Throwable> void throwUnchecked(@NotNull @NotNull Throwable throwable) throws T Throws the given exception as an unchecked exception removing the need to catch non-runtime exceptions.- Type Parameters:
T- the inferred type of the throwable.- Parameters:
throwable- the throwable to rethrow.- Throws:
T- the exception to rethrow.NullPointerException- if the given throwable is null.
-
isFatal
Get if the given exception is an unrecoverable error which prevents the program to resume (on the current thread).- Parameters:
throwable- the throwable to check.- Returns:
- true if the exception is unrecoverable for the current thread, false otherwise.
- Throws:
NullPointerException- if the given throwable is null.
-
rethrowIfFatal
Rethrows the given exception if it signals an unrecoverable error which prevents the program to resume (on the current thread).- Parameters:
throwable- the throwable to rethrow if it is fatal.- Throws:
NullPointerException- if the given throwable is null.
-