You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This caught {@link Throwable} can then be asserted.
1318
1318
* <p>
1319
-
* If you need to assert on the real type of Throwable caught (e.g. IOException), use {@link #catchThrowableOfType(ThrowableAssert.ThrowingCallable, Class)}.
1319
+
* If you need to assert on the real type of Throwable caught (e.g. IOException), use {@link #catchThrowableOfType(ThrowingCallable, Class)}.
* Allows catching an instance of {@link Exception}.
1385
+
* <p>
1386
+
* A call is made to {@code catchThrowable(ThrowingCallable)}, if no exception is thrown it returns null
1387
+
* otherwise it checks that the caught {@link Throwable} is of type {@link Exception} and casts it making it convenient to perform subtype-specific assertions on it.
1388
+
* <p>
1389
+
* Example:
1390
+
* <pre><code class='java'>
1391
+
* Exception exception = catchException(() -> {throw new Exception("boom!");});
1392
+
* // assertions succeed
1393
+
* assertThat(exception).hasMessage("boom!");
1394
+
*
1395
+
* // succeeds as catchException returns null when the code does not throw any exceptions
* Allows catching an instance of {@link RuntimeException}.
1412
+
* <p>
1413
+
* A call is made to {@code catchThrowable(ThrowingCallable)}, if no exception is thrown it returns null
1414
+
* otherwise it checks that the caught {@link Throwable} is of type {@link RuntimeException} and casts it making it convenient to perform subtype-specific assertions on it.
1415
+
* <p>
1416
+
* Example:
1417
+
* <pre><code class='java'>
1418
+
* RuntimeException runtimeException = catchRuntimeException(() -> {throw new RuntimeException("boom!");});
* Allows catching an instance of {@link NullPointerException}.
1439
+
* <p>
1440
+
* A call is made to {@code catchThrowable(ThrowingCallable)}, if no exception is thrown it returns null
1441
+
* otherwise it checks that the caught {@link Throwable} is of type {@link RuntimeException} and casts it making it convenient to perform subtype-specific assertions on it.
1442
+
* <p>
1443
+
* Example:
1444
+
* <pre><code class='java'>
1445
+
* NullPointerException nullPointerException = catchNullPointerException(() -> {throw new NullPointerException("boom!");});
* Allows catching an instance of {@link IllegalArgumentException}.
1466
+
* <p>
1467
+
* A call is made to {@code catchThrowable(ThrowingCallable)}, if no exception is thrown it returns null
1468
+
* otherwise it checks that the caught {@link Throwable} is of type {@link IllegalArgumentException} and casts it making it convenient to perform subtype-specific assertions on it.
1469
+
* <p>
1470
+
* Example:
1471
+
* <pre><code class='java'>
1472
+
* IllegalArgumentException illegalArgumentException = catchIllegalArgumentException(() -> {throw new IllegalArgumentException("boom!");});
* Allows catching an instance of {@link IOException}.
1493
+
* <p>
1494
+
* A call is made to {@code catchThrowable(ThrowingCallable)}, if no exception is thrown it returns null
1495
+
* otherwise it checks that the caught {@link Throwable} is of type {@link IOException} and casts it making it convenient to perform subtype-specific assertions on it.
1496
+
* <p>
1497
+
* Example:
1498
+
* <pre><code class='java'>
1499
+
* IOException iOException = catchIOException(() -> {throw new IOException("boom!");});
1500
+
* // assertions succeed
1501
+
* assertThat(iOException).hasMessage("boom!");
1502
+
*
1503
+
* // succeeds as catchIOException returns null when the code does not throw any exceptions
* Allows catching an instance of {@link ReflectiveOperationException}.
1520
+
* <p>
1521
+
* A call is made to {@code catchThrowable(ThrowingCallable)}, if no exception is thrown it returns null
1522
+
* otherwise it checks that the caught {@link Throwable} is of type {@link ReflectiveOperationException} and casts it making it convenient to perform subtype-specific assertions on it.
1523
+
* <p>
1524
+
* Example:
1525
+
* <pre><code class='java'>
1526
+
* ReflectiveOperationException reflectiveOperationException = catchReflectiveOperationException(() -> {throw new ReflectiveOperationException("boom!");});
* Allows catching an instance of {@link IllegalStateException}.
1547
+
* <p>
1548
+
* A call is made to {@code catchThrowable(ThrowingCallable)}, if no exception is thrown it returns null
1549
+
* otherwise it checks that the caught {@link Throwable} is of type {@link IllegalStateException} and casts it making it convenient to perform subtype-specific assertions on it.
1550
+
* <p>
1551
+
* Example:
1552
+
* <pre><code class='java'>
1553
+
* IllegalStateException illegalStateException = catchIllegalStateException(() -> {throw new IllegalStateException("boom!");});
* Allows catching an instance of {@link IndexOutOfBoundsException}.
1574
+
* <p>
1575
+
* A call is made to {@code catchThrowable(ThrowingCallable)}, if no exception is thrown it returns null
1576
+
* otherwise it checks that the caught {@link Throwable} is of type {@link IndexOutOfBoundsException} and casts it making it convenient to perform subtype-specific assertions on it.
1577
+
* <p>
1578
+
* Example:
1579
+
* <pre><code class='java'>
1580
+
* IndexOutOfBoundsException indexOutOfBoundsException = catchIndexOutOfBoundsException(() -> {throw new IndexOutOfBoundsException("boom!");});
0 commit comments