Checked exceptions

We cannot throw checked exceptions from the producer and the subscriber. Each of the respective Reactor methods take a Consumer function, without any exception declarations. So, the implementations cannot throw it. However, there are scenarios where the producer invokes resources, such as files, which can throw checked exceptions. Reactor provides the Exceptions utility class for handling such scenarios. The Exceptions class provides a propagate method, which can wrap any checked exception into an unchecked exception, as follows:

      @Test    public void testCheckedExceptions() {        Flux<Long> fibonacciGenerator = Flux.generate(() -> Tuples.<Long,                Long>of(0L, 1L), (state, sink) -> {            try {                raiseCheckedException(); } catch (IOException ...

Get Hands-On Reactive Programming with Reactor now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.