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 89869 - Add Catch-Clause to surrounding try-catch block.
Summary: Add Catch-Clause to surrounding try-catch block.
Status: RESOLVED DUPLICATE of bug 75741
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-22 15:11 UTC by elishae
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description elishae 2006-11-22 15:11:55 UTC
(I am trying to promote NetBeans as defacto IDE for our team and one of the 
reviewers came up with the following note. I thought I'd file an issue for 
this).

 If Current code block in surrounded with a try-catch and attempted to call an 
API which throws a checked Exception, NetBeans shows and error and offers two 
solutions 'add throws clause' and 'surround with try catch'. Which results in a 
nested try-catch block. 
 However, it would be nice if it could provide an extra option 'Add catch 
clause to surrounding try'.

PS: Eclipse do provide this extra option which is lot convenient to developers.

Code Example:

try {
   if (!conditionMet) {
       wait();
   }
   /// Rest of Code.
} 
catch (InterruptedException ex) {
 //handle interrupted.
}

if the above code is modified as:

try {
   if (!conditionMet) {
       wait();
   }
   /// Rest of Code.
   if (errorInReadingData) {
      throw new IOException("Error Reading Data");
   }
} 
catch (InterruptedException ex) {
 //handle interrupted.
}

NetBeans offers to modify code as:
try {
   if (!conditionMet) {
       wait();
   }
   /// Rest of Code.
   try {
       if (errorInReadingData) {
           throw new IOException("Error Reading Data");
       }
   } catch (IOException ex) {
       //Handle ex.
   }
} catch (InterruptedException ex) {
 //handle interrupted.
}

It would be good, if NetBeans offers to modify code as 

try {
   if (!conditionMet) {
       wait();
   }
   /// Rest of Code.
   if (errorInReadingData) {
      throw new IOException("Error Reading Data");
   }
} catch (InterruptedException ex) {
     //handle interrupted.
} catch (IOException ex) {
     // handle IOEx
}
Comment 1 Jiri Prox 2006-11-27 12:43:33 UTC
It's duplicate of issue 75741. This behaviour will be introduced in next version.

*** This issue has been marked as a duplicate of 75741 ***
Comment 2 Quality Engineering 2007-09-20 09:44:33 UTC
Reorganization of java component