Reputation: 517
I'm currently using retry()
to re-subscribe to my Observable
if an error occurs.
In this way my Subscriber
's onError
is not called: there is a way to let onError
be called and THEN re-subscribe to the Observable
?
Upvotes: 3
Views: 1038
Reputation: 2390
By the Observable Contract If you invoke onError then your observable will not emit any more items. For this reason alone I do not think that you should try implement it this way(allowing the error to propagate to the subscriber).
If you want to execute any action upon an error then try to use doOnError()
before retry()
.
So your code could look like this:
getObservableThatMaybeEmitsTheError()
.doOnError(throwable -> LogTheErrorMethod(throwable))
.retry()
...
.subscribe()
Upvotes: 8