You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ola Berg <ol...@arkitema.se> on 2002/06/15 17:03:07 UTC

Re: [collection] Transformer exception handling

This is one of the two reasons why I don\'t use jakartas framework (yet) but stick to my own. The generic transforming method needs to be declared as throwing exceptions. 

My Transformation interface (a Transformation is the thing doing the Transformation from one class to another, the Transformer is the surrounding framework) throws InstantiationException and InvocationTargetException (since some reflection almost always is there). InvocationTargetException wraps another Exception, and this is how java.lang.reflect deals with it.

At one time, I let it throw Exception, but I have changed into the two mentioned.

/O

--------------------
ola.berg@arkitema.se
0733 - 99 99 17

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections] Transformer exception handling

Posted by Peter Koßek <Pe...@t-online.de>.
Yes, it is better to use a special wrapper exception like
InvocationTargetException than to use Exception.
But it is no good having a separate ExceptionalTransformer interface. E.g.,
if someone supplies reusable static constants (e.g., a
TO_STRING_TRANSFORMER), and if these constants are instances which implement
Transformer, then you can't reuse the constants within a special framework
which uses ExceptionalTransformer. So it would be very useful if Transformer
is a subtype of ExceptionalTransformer. :-y

----- Original Message -----
From: "Ola Berg" <ol...@arkitema.se>
To: <co...@jakarta.apache.org>
Sent: Saturday, June 15, 2002 5:03 PM
Subject: Re: [collection] Transformer exception handling


> This is one of the two reasons why I don\'t use jakartas framework (yet)
but stick to my own. The generic transforming method needs to be declared as
throwing exceptions.
>
> My Transformation interface (a Transformation is the thing doing the
Transformation from one class to another, the Transformer is the surrounding
framework) throws InstantiationException and InvocationTargetException
(since some reflection almost always is there). InvocationTargetException
wraps another Exception, and this is how java.lang.reflect deals with it.
>
> At one time, I let it throw Exception, but I have changed into the two
mentioned.
>
> /O
> --------------------
> ola.berg@arkitema.se
> 0733 - 99 99 17



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collection] Transformer exception handling

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Ola Berg" <ol...@arkitema.se>
> This is one of the two reasons why I don\'t use jakartas framework (yet)
but stick to my own. The generic transforming method needs to be declared as
throwing exceptions.
>
> My Transformation interface (a Transformation is the thing doing the
Transformation from one class to another, the Transformer is the surrounding
framework) throws InstantiationException and InvocationTargetException
(since some reflection almost always is there). InvocationTargetException
wraps another Exception, and this is how java.lang.reflect deals with it.

I don't agree with the comment  "some reflection almost always is there".  I
believe there are plenty of transformations that don't need reflection.

> At one time, I let it throw Exception, but I have changed into the two
mentioned.

If it was to have an exception, Exception seems most appropriate. However, I
doubt we'll change the commons Transformer interface, and I wouldn't want
to.

Stephen



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>