Skip to content

Commit e21dac0

Browse files
sleyzerzonpivovarit
authored andcommitted
Update VavrUnitTest.java (eugenp#3611)
sample of re-throwing via Try
1 parent 70fd753 commit e21dac0

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ public void givenBadCode_whenTryHandles_thenCorrect2() {
216216
assertEquals(-1, errorSentinel);
217217
}
218218

219-
// @Test(expected = ArithmeticException.class)
220-
// public void givenBadCode_whenTryHandles_thenCorrect3() {
221-
// Try<Integer> result = Try.of(() -> 1 / 0);
222-
// result.getOrElseThrow(ArithmeticException::new);
223-
// }
219+
@Test(expected = RuntimeException.class)
220+
public void givenBadCode_whenTryHandles_thenCorrect3() {
221+
Try<Integer> result = Try.of(() -> 1 / 0);
222+
result.getOrElseThrow(e->new RuntimeException(e));//re-throw different ex type
223+
}
224224

225225
// lazy
226226
@Test

0 commit comments

Comments
 (0)