抓到的Throwable或异常为null [英] Caught Throwable or Exception is null

查看:2341
本文介绍了抓到的Throwable或异常为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个类似的问题被要求在这里两次,从未有任何答案。或者,得到的答复是:这是不可能的!遗憾,有可能太多:

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:

try{
    ...
    // the line that causes the error
    LinearLayout cell = (LinearLayout) inflater.inflate(R.layout.channels_list_cell, column);
    ...
}
catch(Throwable e){
    Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show(); < breakpoint here!
}

目前断点e为空。我该如何寻找错误,请?很可能这不是Java或者Android的问题,但Eclipse的调试器,这本身需要调试严重。但是,我有什么,除了更换不同的IDE做的,?有任何想法吗?在此之前感激不尽。

At the breakpoint e is null. How can I seek for the error, please? Very possibly it is not the problem of java or Android, but of the Eclipse debugger, that itself needs debugging badly. But what have I to do, except changing to a different IDE? Any ideas? Beforehand grateful.

我已经试过的Throwable,异常的RuntimeException。的结果是相同的。

I have tried Throwable, Exception, RuntimeException. The result is the same.

要迈过去的断点,将导致NullPointerException异常,所以,E看来真的是空的那一刻了。凡可能它会丢失?

An attempt to step over breakpoint causes NullPointerException, so, e seems really null at that moment already. Where could it be lost?

编辑: 我把我的谢意给大家,并+1到每个回答者。这是一个Eclipse的bug。重启后的Eclipse的例外是不是空了,这是一个正常的RuntimeException:二进制XML文件中的行#15:你必须提供一个layout_width属性。这将是要解决的另一个问题,但是这一个得以解决。

I bring my gratitudes to everybody and +1 to every answerer. It was an Eclipse bug. After restart Eclipse the Exception is not null anymore, it is a normal RuntimeException: Binary XML file line #15: You must supply a layout_width attribute. It would be another problem to be solved, but this one is solved.

推荐答案

如果你抓住了例外是一个NullPointerException异常时,getMessage()方法返回空,这可能会产生混淆。我知道,这有时糊涂了!

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!

在调试器,你应该能够选择e,看到一个类型及其字段。此外,另一种方式,当事情变得很混乱调试是去

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();

(注意! - 我不是一个Android大师,所以如果这个原理不同Android上有人请评论)

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

这篇关于抓到的Throwable或异常为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆