The onError method of Rxjava locates the NULL pointer details, rxjavaonerror

Source: Internet
Author: User

The onError method of Rxjava locates the NULL pointer details, rxjavaonerror
The onError method of Rxjava locates a null pointer.

Recently, we have been using kotlin + Rxjava to write projects. A null pointer is encountered (the null is located later to be printed ). The situation is as follows:

Override fun onError (e: Throwable) {Log. e (TAG, "onError:" + e )}

NULL pointer? Meaning. Take a closer look: No positioning?
No location !!!
No location !!!
No location !!!
Let's just ask, are you never desperate? There are about 40 operations in my onNext method. Where can I find this NULL pointer?
Maybe you will say: Won't you write a Global Capture exception? I personally think that writing so much code in try-catch is too low.
After studying for more than an hour, find the solution:

Override fun onError (e: Throwable) {Log. e (TAG, "onError:" + e) e ?. StackTrace ?. ForEach {Log. e (TAG, "stackTrace --- element:" + it ?. ToString ())}}

Conclusion

In Baidu's solutions, I really felt helpless. There are no similar cases at all. They are all about error handling operators. It may be because they don't need to write them out. I can only go to official documents if I cannot find Baidu. In fact, it is faster to see the document to solve the problem.
StackTrace cannot be printed directly, and the memory value is printed directly. Traversal is required.

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.