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.