Error handling
The Observables contain a couple of operators that allow error handling, swallowing exceptions, transforming exceptions, call-finally blocks, retrying the failed sequence, and disposing resources even if an error occurs.
The catch operator
These operators enable recovering from errors by continuing the sequence:
onErrorResumeNext: Instructs an Observable to pass control to another Observable given by a supplier, instead of invokingonErrorwhen something goes wrongonErrorReturn: Instructs an Observable to emit a default supplied by a function, in case of erroronErrorReturnItem: Instructs an Observable to emit a supplied default, in case of erroronExceptionResumeNext: Instructs an Observable to pass control to another Observable instead of invokingonErrorin case something goes wrong
The following example shows how to use the onErrorReturnItem method; calling it without the flatMap trick will stop the flow and output Default at the end. By deferring the call to the exception...