When using Observables with Retrofit how do you handle Network failure?
Given this code:
Observable observable = api.getApiService(
My problem was actually elsewhere in my code. Handling network errors with rxJava + Retrofit is very easy as it just throws a RetrofitError in the onError method:
@Override
public void onError(Throwable e) {
if (e instanceof RetrofitError) {
if (((RetrofitError) e).isNetworkError()) {
//handle network error
} else {
//handle error message from server
}
}
}