classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NotYetImplementedError [Was: NYIException]


From: Stephen Crawley
Subject: Re: NotYetImplementedError [Was: NYIException]
Date: Mon, 29 Sep 2003 13:48:52 +1000

> I personally think that a Java application should not try to discover 
> the JVM/library version through an akward usage of exceptions/errors.

I personally disagree that it is awkward. 

> Many applications (including SableCC, I think) do things like:
> 
> try ...
> catch(Exception e)
> {...}
>
> In such context, a missing method is definitely *not* an exception.

Catching Exception or RuntimeException is usually a good indication that
the application's exception handling is broken.  In my experience, there
are only two cases where an ordinary application should catch Exception
or RuntimeException:

  *  so that you can report exception that would otherwise disappear
     into the aether; (e.g. in a non-main thread), or

  *  so that you can record an exception in the application's error log.

Anything else and the application risks squashing serious exceptions and 
doing inappropriate recovery.

In the context above, an unimplemented method is no more or less an
Exception than NullPointerException or UnsupportedOperationException.
In each case, the exception is probably an application error, but the
application could conceivably recover and continue.  Thus, if we were
to invent a new exception/error, a subtype of RuntimeException would
be the most appropriate.

-- Steve





reply via email to

[Prev in Thread] Current Thread [Next in Thread]