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.
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.
Surely this would be nice improvement.
Would prevent you getting a mess of nested try catch blocks that you have to manually tidy, which is currently the case.
Changing subcomponent.
*** Issue 89869 has been marked as a duplicate of this issue. ***
Tested in 6.0 M10 and looks like this is not yet implemented. Please verify.;
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.
In 6.1 there are now hints for both possibilities - adding catch clause to existing try -catch and creating new try-catch statement
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.
I've tested the behavior in 7.0 M1 and hence reopened it against 7.0
Solved in 7.3 *** This bug has been marked as a duplicate of bug 207480 ***