Handling errors

When we design a reactive application that communicates a lot with external services, we have to deal with all kinds of exceptional situations. Fortunately, the onError signal is an integral part of the Reactive Stream specification, so an exception should always have a way to propagate to the actor who can handle it. However, if the final subscriber does not define a handler for the onError signal, onError throws an UnsupportedOperationException.

Also, the semantics of Reactive Streams define that onError is a terminal operation, after which the reactive sequence stops executions. At that point, we may react differently by applying one of the following strategies:

  • Of course, we should define handlers for the onError signal ...

Get Hands-On Reactive Programming in Spring 5 now with O’Reilly online learning.

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