Fhurrur
Fhurrur

Reputation: 61

Highlight unchecked exception in catch in intelliJ

I'm in the process of moving to intelliJ from eclipse but I've stumbled upon a highlighting problem with exceptions in catch clauses. This is somewhat linked to Highlight exception throwers in IntelliJ IDEA

Given example code as follows:

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

and positioning the cursor on the NumberFormatException in eclipse will highlight where it is thrown as in

enter image description here

but in intelliJ I haven't been able to reproduce this: enter image description here

I've tried highlight usage in file when placing the caret on both the catch and the NumberFormatException but it doesn't work, what am I doing wrong?

It is the same when doing it in the method signature, eclipse:

enter image description here

but not in intelliJ

enter image description here

Is it possible to get this in the same way as in eclipse?

EDIT

As explained by yole in one of the answers this is specific to unchecked exceptions in IntelliJ even if they are declared in the method signature as in the case for Double.parseDouble(String) throws NumberFormatException()

Upvotes: 3

Views: 1621

Answers (2)

yole
yole

Reputation: 97288

In IntelliJ IDEA, to see where an exception is thrown, you need to put the caret on the catch keyword, not on the exception class name.

Upvotes: 5

LppEdd
LppEdd

Reputation: 21154

Apparently you need a key-combination: Ctrl + Shift + F7

See https://intellij-support.jetbrains.com/hc/en-us/community/posts/206269539-how-can-I-see-in-intellij-where-exception-is-thrown-

Upvotes: 0

Related Questions