onErrorReturn method
Instructs a Single to emit a particular item when it encounters an error, and then terminate normally.
The onErrorReturn operator intercepts an onError notification from the source Single. Instead of passing it through to any observers, it replaces it with a given item, and then terminates normally.
If you need to perform logic based on the type of error that was emitted, please consider using onErrorReturnWith.
Marble
single : ----------x|
returnValue : a
result : ----------a|
NOTE: x is error event
Example
Single<int>.error(Exception())
.onErrorReturn(1)
.listen(print); // prints 1
Implementation
Single<T> onErrorReturn(T returnValue) =>
Single.safe(Stream<T>.eventTransformed(
this, (sink) => _OnErrorReturnSingleSink<T>(sink, returnValue)));