I have a RXJava chain where an error can be thrown. I would like the chain to continue and ignore the error and reach the subscribe, for only some specific errors.
For example in this code
authDataManager
.getUserAccessToken(username, password)
.subscribeOn(Schedulers.io())
.doOnNext({
authDataManager.saveUserAccessToken(it)
})
.flatMap {
appDataManager.getStations()
}
.doOnNext({
appDataManager.persistStations(it)
})
.flatMap {
appDataManager.getDriverInformation()
}
.doOnNext({
appDataManager.persistDriverInformation(it)
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
onLoginSuccess()
},
{
onLoginFailure(it)
}
)
if appDataManager.getStations() throws an error, I still want to continue and reach the onLoginSuccess() method.
However if getUserAccessToken(username, password) fails, onLoginFailure should be called.
I have tried to add onErrorResumeNext() and onExceptionResumeNext() after the flatmaps and inside them, but if I do that, the chain just exits and doesn't continue and reach the subscribe