How can I map one occurred exception to another one in RxJava2? For example:
doOnError(throwable -> {
if (throwable instanceof FooException) {
throw new BarException();
}
})
In this case I finally receive CompositeException
that consists of FooException
and BarException
, but I'd like to receive only BarException
. Help!
You can use onErrorResumeNext and return Observable.error() from it:
Edit
This test passes for me: