Caught Throwable or Exception is null

后端 未结 5 1105
后悔当初
后悔当初 2021-01-19 01:45

A similar question was asked here for two times and never there was any answer. Or the answer was: \"it is impossible!\" Sorry, it is possible too much:

         


        
5条回答
  •  [愿得一人]
    2021-01-19 02:30

    If the exception you caught was a NullPointerException, the getMessage() method returns "null" which may be confusing. I know that this has sometimes confused me!

    In the debugger, you should be able to select e and see a type and its fields. Also, another way to debug when things get really confusing is to go

     e.printStackTrace();
    

    (note - I'm not an Android guru so if this works differently on Android somebody please comment!)

提交回复
热议问题