This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 75741 - add clause to existing try-catch block
Summary: add clause to existing try-catch block
Status: RESOLVED DUPLICATE of bug 207480
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: Jan Lahoda
URL:
Keywords:
: 89869 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-01 14:49 UTC by kenneth_suter
Modified: 2013-02-08 20:30 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kenneth_suter 2006-05-01 14:49:06 UTC
If a try-catch block already surrounds a method call that
potentially throws mulitple exceptions but the try-catch doens't catch
all of them, NetBeans correctly signals an error.  The light bulb lists
two options:  "Add throws clause [to the current method signature] for
XXXException" and "surround with try-catch".  Idea allows a third option
for adding the new catch clause to the existing try-catch block which is
very useful. 

This is a very useful feature already part of IntelliJ IDEA.
Comment 1 _ rkubacki 2006-05-02 19:45:11 UTC
Surely this would be nice improvement.
Comment 2 sard 2006-06-11 12:13:09 UTC
Would prevent you getting a mess of nested try catch blocks that you have to
manually tidy, which is currently the case.
Comment 3 Pavel Flaska 2006-06-12 16:36:10 UTC
Changing subcomponent.
Comment 4 Jiri Prox 2006-11-27 12:43:28 UTC
*** Issue 89869 has been marked as a duplicate of this issue. ***
Comment 5 elishae 2007-07-31 06:57:24 UTC
Tested in 6.0 M10 and looks like this is not yet implemented. Please verify.;
Comment 6 Jiri Prox 2007-07-31 08:17:48 UTC
The bahaviour of try-catch hint was changed in 6.0, now it surrounds the whole body of the actual block and adds catch
statement to the surrounding try-catch if there is any. 
Comment 7 Jiri Prox 2008-03-27 08:51:03 UTC
In 6.1 there are now hints for both possibilities - adding catch clause to existing try -catch and creating new
try-catch statement 
Comment 8 elishae 2008-12-30 05:19:55 UTC
Re-opening the issue, as it is only partially implemented.

for e.g. in the error hints, 

selecting 'surround block with try catch', adds a catch clause to existing block.

whereas, selecting 'surround statement with try catch', inserts a new inner try catch block.

Also, having such ambiguous names is an usability issue. IMHO, I would have the hints displayed as

1. Surround with try-catch block
2. "Add a catch clause to surrounding try block"
3. Add throws clause...

I feel, text in proposed 2nd option avoids the confusion to user.


Comment 9 elishae 2008-12-30 05:20:50 UTC
I've tested the behavior in 7.0 M1 and hence reopened it against 7.0
Comment 10 markiewb 2013-02-08 20:30:29 UTC
Solved in 7.3

*** This bug has been marked as a duplicate of bug 207480 ***