Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 18687 - Surround with try catch - should propose NumberFormatException
Summary: Surround with try catch - should propose NumberFormatException
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC1   Edit
Assignee: Dirk Baeumer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 20770 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-06-03 07:41 EDT by Philipe Mulet CLA
Modified: 2004-06-15 18:56 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2002-06-03 07:41:51 EDT
Build F2

From EC:

Hi all!
I'd like to know  if the following is a bug or is the normal behaviour of
eclipse.
1) type the code below:
int t= Integer.parseInt("1234");
2) select the line   typed in  the step 1.
3) try to "surround with try/catch".
I do this by pressing alt+S T.
Eclipse gives the following messsage:
No uncaught exceptions are thrown by the selected code. Catch
java.lang.RuntimeException ?

I think that eclipse should suggest  something like:
try {

....

} catch (NumberFormatException e) {

}
Comment 1 Philipe Mulet CLA 2002-06-03 07:42:56 EDT
I think Jose's argument is valid. The exception is declared in the target
method signature, and
it is a valid one to catch on purpose.
Comment 2 Dirk Baeumer CLA 2002-06-04 05:41:22 EDT
Surround with try/catch was implemented that way but I had to remove the 
functionality because of another bug. The decision was not to catch runtime 
exceptions. Since Surround with Try/Catch doesn't have a UI the only change is 
to add a global preference
Comment 3 Philipe Mulet CLA 2002-06-04 09:46:27 EDT
I think it should never ignore declared exceptions no matter what.
Comment 4 Erich Gamma CLA 2002-06-08 19:29:35 EDT
not for 2.0
Comment 5 Stanimir Stamenkov CLA 2002-06-21 04:12:45 EDT
I just found I've filled a duplicate bug report for this in a hurry - bug#20770.
I'm pretty new to bugzilla and I'm sorry for any inconvenience I caused with this.
Comment 6 Dirk Baeumer CLA 2002-06-21 06:44:42 EDT
*** Bug 20770 has been marked as a duplicate of this bug. ***
Comment 7 Dirk Baeumer CLA 2002-07-22 08:26:20 EDT
Reopening
Comment 8 Dirk Baeumer CLA 2003-02-20 10:06:13 EST
Now all exception are caught which are declared in the Javadoc.

Fixed for RC1. 
Comment 9 Tony Poppleton CLA 2004-06-15 18:39:26 EDT
I don't understand the last comment.  I have tried the following piece of 
code...

public class RuntimeExceptionTest
{
 /**
  * 
  * @throws RuntimeException
  */
 public void test() throws RuntimeException
 {
 }

 public void nowarning()
 {
  //the call to test should show a warning that a RuntimeException is
  //thrown and offer the quick fix to either wrap it in a try catch
  //block, or propagate the exception
  test();
 }
}

The javadoc doesn't seem to affect the behaviour, or does it need to be the 
actual html javadoc?

In any case, it would be good if it could use the method signature, as oppose 
to only relying on the javadoc.

Could a compiler setting allow this to be on either ignore/warning/error?