I am just starting with RxJava, but maybe something else has not clicked.
1.
Integer[] items = {1, 2, 3, 0, 0, 4, 5, 6, 1};
Observable.from(items)
.map(this::invert)
.subscribe(i -> Log.d(LOG_TAG, "Inverted: " + i), t -> Log.d(LOG_TAG, "Error: " + t.getMessage()));
2.
Integer[] items = {1, 2, 3, 0, 0, 4, 5, 6, 1};
Observable.from(items)
.map(this::invert)
.doOnError(t -> Log.d(LOG_TAG, "Error: " + t.getMessage()))
.doOnNext(i -> Log.d(LOG_TAG, "Inverted: " + i))
.subscribe();
Function invert:
int invert(int i) {
return 1 / i;
}
The first is executed normally, and when an exception is thrown, it is executed onError. But, on the other hand, the second does not work, so the exception extends all the way to the calling method.
What is the difference between two blocks of code?