突出显示intelliJ中catch中未经检查的异常

时间:2017-03-08 13:14:38

标签: java intellij-idea

我正在从eclipse转移到intelliJ,但我偶然发现了一个突出问题,其中包含了catch子句中的异常。这与Highlight exception throwers in IntelliJ IDEA

有些联系

给出示例代码如下:

try {
    System.out.print(Double.parseDouble("throws exception"));
} catch (NumberFormatException e){
    System.out.print(e.toString());
}

并将光标定位在eclipse中的NumberFormatException上会突出显示它在哪里被抛出

enter image description here

但是在智能方面,我还没有能够重现这一点:enter image description here

我把插入符号放在捕获符号和highlight usage in file上时尝试NumberFormatException但它不起作用,我做错了什么?

在方法签名中执行此操作时,它是相同的, 蚀:

enter image description here

但不是在intelliJ

enter image description here

是否有可能以与日食相同的方式获得此信息?

修改

正如其中一个答案中的yole所解释的那样,这特定于IntelliJ中未经检查的异常,即使它们在方法签名中声明,如同Double.parseDouble(String) throws NumberFormatException()

的情况一样

2 个答案:

答案 0 :(得分:3)

在IntelliJ IDEA中,要查看抛出异常的位置,您需要将插入符号放在catch关键字上,而不是放在异常类名称上。

答案 1 :(得分:0)

相关问题