Comments on: Checked Exceptions are Waste https://andypalmer.com/2008/09/checked-exceptions/ Views on software, technology, consulting and business process Mon, 21 Sep 2009 10:23:13 +0000 hourly 1 https://wordpress.org/?v=6.4.3 By: Kevin Wong https://andypalmer.com/2008/09/checked-exceptions/comment-page-1/#comment-1062 Mon, 21 Sep 2009 10:23:13 +0000 http://www.andypalmer.com/blog/?p=13#comment-1062 I always change my Eclipse default catch clause to:
throw new RuntimeException(e);

Don't add and exception to the throws clause unless it will make sense to the caller. If it's a case that should never happen, or cannot be handled, wrap it in a RuntimeException, which effectively converts the checked exception to an unchecked one.

I don't see why an “ignores” clause couldn't be added to Java methods to do this wrapping automatically.

]]>
By: Andy Palmer » Installing Eclipse https://andypalmer.com/2008/09/checked-exceptions/comment-page-1/#comment-128 Sun, 22 Feb 2009 23:11:02 +0000 http://www.andypalmer.com/blog/?p=13#comment-128 […] also discussed my thoughts on checked exceptions. I prefer to not silently hide the exception with a stack trace, I also don’t want to make my […]

]]>
By: Steve Freeman https://andypalmer.com/2008/09/checked-exceptions/comment-page-1/#comment-26 Sun, 09 Nov 2008 18:25:44 +0000 http://www.andypalmer.com/blog/?p=13#comment-26 The reason Java checked exceptions are a pain is because, like everything in Java, they didn’t quite finish when they adopted the idea. In Modula-3, there is a FATAL pragma which meant that you can declare that you don’t know how to handle a checked exception within a given scope. If such an exception occurs then the program fails. It’s so simple but it makes all the difference to the usability of checked exceptions.

The point of checked exceptions is that it allows me to know all the paths out of a chunk of code, otherwise I have to assume that any method call can fail and over-protect the logic.

]]>
By: Rugbyhead https://andypalmer.com/2008/09/checked-exceptions/comment-page-1/#comment-21 Sat, 06 Sep 2008 17:27:00 +0000 http://www.andypalmer.com/blog/?p=13#comment-21 Liking the ExceptionHandler object idea, could prove to be very versatile and flexible…
Next workshop?? 😀

]]>