Proposal: Extensible exceptions

Johan Tibell johan.tibell at gmail.com
Mon Jul 7 08:02:54 EDT 2008


On Sun, Jul 6, 2008 at 10:13 PM, Henning Thielemann
<lemming at henning-thielemann.de> wrote:
>  In Modula-3 you have to add the exceptions that can be raised to a
> PROCEDURE header. Java has adopted this mechanism.

Many people argue that this was a mistake [1, 2, 3, 4]. For one it
requires that you rewrap exceptions at every abstraction boundary or
expose your implementation details in the API. For example, imagine
that you decide to use an SQL database as a data store and declare
that your functions throw an SQLException. If you later change your
mind and want to use a plain file for storage you need to change your
function's type and thereby break clients that use your API. If you
don't want this to happen you have to wrap all exception in
MyException and throw that.

1. http://radio.weblogs.com/0122027/stories/2003/04/01/JavasCheckedExceptionsWereAMistake.html
2. http://www.mindview.net/Etc/Discussions/CheckedExceptions
3. http://www.ibm.com/developerworks/java/library/j-jtp05254.html
4. http://www.oreillynet.com/onjava/blog/2004/09/avoiding_checked_exceptions.html

Cheers,

Johan


More information about the Libraries mailing list