how can I see in intellij where exception is thrown?

how can I see in intellij where an exception is thrown? Like in this example, which code line(s) do actually throw the IOException?


private void writeObject(java.io.ObjectOutputStream s)
        throws IOException
    {
    Iterator<Map.Entry<K,V>> i =
        (size > 0) ? entrySet0().iterator() : null;

    // Write out the threshold, loadfactor, and any hidden stuff
    s.defaultWriteObject();

    // Write out number of buckets
    s.writeInt(table.length);

    // Write out size (number of Mappings)
    s.writeInt(size);

        // Write out keys and values (alternating)
    if (i != null) {
        while (i.hasNext()) {
        Map.Entry<K,V> e = i.next();
        s.writeObject(e.getKey());
        s.writeObject(e.getValue());
        }
        }
    }

13 comments
Comment actions Permalink

Hi Tilman,

You can comment 'throws' declaration and IDEA automatically hightlights problem places.

Regards, Denis.

0
Comment actions Permalink

ok, that's what I feared...well, that's one of the few things that eclipse handles nicer...but still..response time to forum questions is unmatched in the business

0
Comment actions Permalink

Place the caret at throws keyword and press Ctrl+Shift+F7.
Or if you want eclipse-style highlighting (always automatically highhlight usages) then go to Settings | Editor and mark check box 'Highlight usages of element at caret'.

0
Comment actions Permalink

trigger ctrl++shift+f7 on "throws" (or on "catch" when try catch)

0
Comment actions Permalink

trossmy wrote:
ok, that's what I feared...well, that's one of the few things that eclipse handles nicer...but still..response time to forum questions is unmatched in the business:)

Checked IDEA facilities one more time and found that you can manage to get desired result in more convenient way - put caret on 'throws' keyword and press 'Ctrl + Shift + F7' ('highlight usages').

0
Comment actions Permalink

ok, that's much better...still my colleague that is a freshly converted ex eclipse user, is only partially satisfied...
thx
Tilman

0
Comment actions Permalink

trossmy wrote:

ok, that's much better...still my colleague that is a freshly converted ex eclipse user, is only partially satisfied...
thx
Tilman


Any concrete reasons for that over than habit to use another IDE?

0
Comment actions Permalink

As an intellij evangelist I hate to admit that I find the eclipse way, where you just put the caret at the exception in the throws declaration and then see where it is thrown,
much easier (and much more intuitive) then putting the caret at the throws keyword and then after pressing ctrl+shift+F7 having to choose which exception I want to see...
(see attached eclipse screenshots)



Attachment(s):
eclipse2.png
eclipse1.png
2
Comment actions Permalink

see reply above:

Or if you want eclipse-style highlighting (always automatically highhlight usages) then go to Settings | Editor and mark check box 'Highlight usages of element at caret'.
0
Comment actions Permalink

Got the point but there is a field to discuss

Current IDEA behavior with enabled auto-highlighting it to show all exception usages within the current class:

idea-highlight-exception.png
(all listed exceptions are highlighted within the method body when caret is on 'throws': )

idea-highlight-exception2.png
Both features are useful and I can't say that one of them has more value than another.

That may be the case to add a setting that allows to toogle behavior to use - feel free to submit corresponding ticket to IDEA tracker, will check community feedback.

0
Comment actions Permalink

well I myself am satisfied with that ctrl+shift+F7 thing (having executed the rather primitive commenting suggested above for years ... and with switched on highlighting (+testcoverage +inspections, which are a must) the editor looks too much like a candystore for my taste anyway)

0
Comment actions Permalink



Cool, thanks!

0
Comment actions Permalink

I see, well, creating an issue may help ;-)

0

Please sign in to leave a comment.