| Summary: | Change default catch block template to throw RuntimeException instead of swallowing | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Nobody - feel free to take it <nobody> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jarthana |
| Version: | 4.6 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | stalebug | ||
|
Description
Nobody - feel free to take it
I don't want to start a debate about the usefulness on checked exceptions. There are some very good arguments in this post (which I'm linking, as I'm quoting from it): http://stackoverflow.com/a/614494/2095738 (pro) http://stackoverflow.com/a/614330/2095738 (contra) What both sides agree on and what every Java developer has learned from experience is that swallowing checked exceptions is about the worst solution. And yet this is exactly what the Eclipse IDE does. [Get] in the habit of whenever you have to handle a checked exception and you're feeling lazy (or you think the API programmer was overzealous in using the checked exception in the first place), don't just swallow the exception, wrap it and rethrow it. try { overzealousAPI(thisArgumentWontWork); } catch (OverzealousCheckedException e) { throw new RuntimeException(e); } Put this in one of your IDE's little code templates and use it when you're feeling lazy. This way if you really need to handle the checked exception you'll be forced to come back and deal with it after seeing the problem at runtime. Because, believe me (and Anders Hejlsberg) you're never going to come back to that TODO in your catch (Exception e) { /* TODO deal with this at some point (yeah right) */} I am sorry, is there a bug report or enhancement request here? If so, can you clearly state what you would like Eclipse to do here? This is an enhancement request. Sorry if this is not the appropriate place to report these. Swallowing checked exceptions is not considered 'good practice' in Java. For that reason, Eclipse - being a Java IDE - should change its default template for a catch block from "swallow and print something" to "rethrow unchecked". (In reply to Tim De Backer from comment #3) > This is an enhancement request. Sorry if this is not the appropriate place > to report these. It is. Sorry, I didn't pay close attention to the bug summary. Moving to UI where the templates belong. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |