On Sat, 2004-11-20 at 05:31, Craig McClanahan wrote:

> How about two lines, which you can already do today?
> 
> try {
>   ...
> } catch (Exception e) {
>   ...
> }

The problem with such approach is that it catches all exception, checked
or not (see below)

> seems to be a standarized "log it and exit" or "log it and rethrow it
> in a wrapper exception" strategy, which you can deal with quite
> easily.

That makes sense for checked exceptions. For instance, when you use
reflection to invoke a method, you have to handle 2 or 3 checked
exceptions, which you typically want to just log and exit as you
described. But if you use a generic catch( Exception e ), you would
catch unchecked exception as well (like NullPointerException).

> Sheesh, hasn't anyone ever heard of inheritance around here?  :-)

Ask the java.lang folks :-)

I mean, there is a good 'inheritance chain' of

 Throwable -> Exception -> RuntimeException -> TheException 

for unchecked exceptions, but for checked exceptions is just

 Throwable -> Exception -> TheException ; 

I think there is a missing class there. If we had something like this:

Throwable -> Exception -> UncheckedException -> RuntimeException
Throwable -> Exception -> CheckedException

Or even just:

Throwable -> Exception -> RuntimeException
Throwable -> Exception -> CheckedException


Then your idea would make sense: we could just use the CheckedException,
without the need for changing the language sintaxe (just the API and
maybe some internal structures in the VM).


-- Felipe



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to