When dealing with errors in RxJava, you should be aware that they terminate the
Observable chain of actions. Much like with your normal procedural code, once you are in the catch block, you can't go back to the code that has thrown the exception. You can execute some backup logic though and use it instead of failing the program. The
resume* operators do something similar.
Observable<String> numbers = Observable .just("1", "2", "three", "4", "5") .map(Integer::parseInt) .onErrorReturn(e -> -1); subscribePrint(numbers, "Error returned");
Integer::parseInt method will succeed in converting the strings
Integer values, but it will fail on
three with a
NumberFormatException exception. This exception will be passed to the...