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