Highlight the block you want to enwrap, go to the top menu under Source
. Choose Surround with Try / Catch Block
.
It will automatically indent the code and list the found exceptions. I think the NumberFormatException
will be listed automatically.
This is basically the same as with UncheckedExceptions, except that with UncheckedExceptions Eclipse will automatically highlight the line as it is a Java Error to ignore (not catch nor rethrow) a checked exception. You probably have used the QuickFix Menu (usually STRG+1 as hotkey, or mouse hover over the error). The menu item above will work even without an error (and thus no error you could use QuickFix for)