When using Observables with Retrofit how do you handle Network failure?
Given this code:
Observable observable = api.getApiService(
Note that if you let an observable emit onError
, all upstream observables will shut down - regardless of whether you "catch" it with onErrorReturn
or onErrorResumeNext
. Often you don't want that. For example, if your stream starts with a button click that triggers a retrofit request which fails, then the button clicks won't be recognized anymore since the stream terminated.
Use Observable
or Observable
to also handle retrofit errors in onNext()
.
s. http://blog.danlew.net/2015/12/08/error-handling-in-rxjava/