parent
3a0d3b93a8
commit
5b60305952
|
@ -978,7 +978,7 @@ public class ExceptionUtils {
|
|||
* @param throwable
|
||||
* The throwable to check.
|
||||
* @return True if the given Throwable is a checked exception.
|
||||
* @since 3.13
|
||||
* @since 3.13.0
|
||||
*/
|
||||
public static boolean isChecked(final Throwable throwable) {
|
||||
return throwable != null && !(throwable instanceof Error) && !(throwable instanceof RuntimeException);
|
||||
|
@ -990,7 +990,7 @@ public class ExceptionUtils {
|
|||
* @param throwable
|
||||
* The throwable to check.
|
||||
* @return True if the given Throwable is an unchecked exception.
|
||||
* @since 3.13
|
||||
* @since 3.13.0
|
||||
*/
|
||||
public static boolean isUnchecked(final Throwable throwable) {
|
||||
return !isChecked(throwable);
|
||||
|
|
|
@ -123,19 +123,19 @@ public class ExceptionUtilsTest extends AbstractLangTest {
|
|||
}
|
||||
}
|
||||
|
||||
private ExceptionWithCause cyclicCause;
|
||||
|
||||
|
||||
private Throwable jdkNoCause;
|
||||
|
||||
private NestableException nested;
|
||||
|
||||
private Throwable notVisibleException;
|
||||
|
||||
private Throwable withCause;
|
||||
|
||||
private Throwable withoutCause;
|
||||
|
||||
private Throwable jdkNoCause;
|
||||
|
||||
private ExceptionWithCause cyclicCause;
|
||||
|
||||
private Throwable notVisibleException;
|
||||
|
||||
private Throwable createExceptionWithCause() {
|
||||
try {
|
||||
try {
|
||||
|
@ -610,6 +610,41 @@ public class ExceptionUtilsTest extends AbstractLangTest {
|
|||
assertEquals(0, ExceptionUtils.indexOfType(withCause, Throwable.class, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_checked() {
|
||||
assertTrue(ExceptionUtils.isChecked(new IOException()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_error() {
|
||||
assertFalse(ExceptionUtils.isChecked(new StackOverflowError()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_null() {
|
||||
assertFalse(ExceptionUtils.isChecked(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_unchecked() {
|
||||
assertFalse(ExceptionUtils.isChecked(new IllegalArgumentException()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUnchecked_checked() {
|
||||
assertFalse(ExceptionUtils.isUnchecked(new IOException()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUnchecked_error() {
|
||||
assertTrue(ExceptionUtils.isUnchecked(new StackOverflowError()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUnchecked_unchecked() {
|
||||
assertTrue(ExceptionUtils.isUnchecked(new IllegalArgumentException()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrintRootCauseStackTrace_Throwable() {
|
||||
ExceptionUtils.printRootCauseStackTrace(null);
|
||||
|
@ -850,39 +885,4 @@ public class ExceptionUtilsTest extends AbstractLangTest {
|
|||
final Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new TestThrowable()));
|
||||
assertTrue(ExceptionUtils.hasCause(t, TestThrowable.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_null() {
|
||||
assertFalse(ExceptionUtils.isChecked(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_unchecked() {
|
||||
assertFalse(ExceptionUtils.isChecked(new IllegalArgumentException()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_checked() {
|
||||
assertTrue(ExceptionUtils.isChecked(new IOException()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_error() {
|
||||
assertFalse(ExceptionUtils.isChecked(new StackOverflowError()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUnchecked_unchecked() {
|
||||
assertTrue(ExceptionUtils.isUnchecked(new IllegalArgumentException()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUnchecked_checked() {
|
||||
assertFalse(ExceptionUtils.isUnchecked(new IOException()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUnchecked_error() {
|
||||
assertTrue(ExceptionUtils.isUnchecked(new StackOverflowError()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue