Better private method name.

This commit is contained in:
Gary Gregory 2021-07-10 10:25:48 -04:00
parent 46094be47e
commit cfe934e2d0
1 changed files with 12 additions and 12 deletions

View File

@ -68,6 +68,17 @@ public class ExceptionUtils {
*/
static final String WRAPPED_MARKER = " [wrapped] ";
/**
* Claims a Throwable is another Exception type using type erasure. This
* hides a checked exception from the Java compiler, allowing a checked
* exception to be thrown without having the exception in the method's throw
* clause.
*/
@SuppressWarnings("unchecked")
private static <R, T extends Throwable> R eraseType(final Throwable throwable) throws T {
throw (T) throwable;
}
/**
* Introspects the {@code Throwable} to obtain the cause.
*
@ -753,7 +764,7 @@ public class ExceptionUtils {
*/
public static <R> R rethrow(final Throwable throwable) {
// claim that the typeErasure invocation throws a RuntimeException
return ExceptionUtils.<R, RuntimeException>typeErasure(throwable);
return ExceptionUtils.<R, RuntimeException>eraseType(throwable);
}
/**
@ -885,17 +896,6 @@ public class ExceptionUtils {
return throwableOf(throwable, type, fromIndex, true);
}
/**
* Claims a Throwable is another Exception type using type erasure. This
* hides a checked exception from the Java compiler, allowing a checked
* exception to be thrown without having the exception in the method's throw
* clause.
*/
@SuppressWarnings("unchecked")
private static <R, T extends Throwable> R typeErasure(final Throwable throwable) throws T {
throw (T) throwable;
}
/**
* Throws a checked exception without adding the exception to the throws
* clause of the calling method. For checked exceptions, this method throws