RxJava----Operator: error handling

Source: Internet
Author: User

These operators are used to recover from error notifications

Catch

Catch is similar to Try/catch in Java, when an error occurs, you can intercept the call to OnError, so that observable does not terminate because of the error. In Rxjava, this operator is implemented as a 3 operator, respectively:

Onerrorreturn

When an error occurs, let observable launch a pre-defined data and terminate it normally.

Onerrorresume

When an error occurs, another observable replaces the current observable and continues to emit data.

Onexceptionresumenext

Similar to Onerrorresume, the difference is that it will be onerror thrown by the data type to judge, if it is exception, will also use another observable instead of the original observable continue to launch data, Otherwise, the error will be distributed to subscriber.

Retry

Retry, if observable fired an error notification, re-subscribe to it and expect it to terminate normally

The retry operator re-subscribes when an error occurs, and can be repeated several times, so the emitted data can be duplicated. If you repeat the specified number of times and there are errors, the error is returned to the Observer

The Rxjava also implements the Retrywhen operator. When an error occurs, Retrywhen receives OnError's throwable as a parameter and returns a observable based on the defined function, and if the observable launches a data, it is re-subscribed.

RxJava----Operator: error handling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.