我正在将 rxjava 1 升级到 rxjava 2。在 rxjava 1 中有 OnErrorThrowable,但在 rxjava 2 中没有。在下面的代码中我可以做什么来替换 OnErrorThrowable?
static Observable<String> sampleObservable() {
return Observable.defer(new Callable<ObservableSource<String>>() {
@Override
public ObservableSource<String> call() throws Exception {
try {
// Do some long running operation
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
} catch (InterruptedException e) {
throw OnErrorThrowable.from(e);
}
Log.d(TAG, "The sleep is over, now produce something");
return Observable.just("one", "two", "three", "four", "five");
}
});
}