You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-dev@incubator.apache.org by Costin Leau <co...@gmail.com> on 2005/10/03 08:59:25 UTC

[jcr-mapping] exceptions

Hello,

another remark on the exceptions from jcr-mapping project. Why isn't
there a base exception and why java.lang.Exception is extended instead
of the javax.jcr.RepositoryException?
As the jcr-mapping is based on a JCR implementation it should extend
the JCR exception hierarchy. Right now the code executing with
jcr-mapping has to do a:

try
{
  .. some code
} catch (RepositoryException re)
{
   // from work on the repository
} catch (JcrMappingException jme)
{
  // from mapping code
}


-- 
Best regards,
 Costin                          mailto:costin.leau@gmail.com


Re[2]: [jcr-mapping] exceptions

Posted by Costin Leau <co...@gmail.com>.
Hello Christophe,

>  try
>  {
>        some code
>  }
>  catch (Exception e)
>  {
>        throw new JcrMappingException("exception message" , e);
>  }

It is correct but it's just a wrapper around the exceptions - plus it
is way to general - it catches all the exceptions including user
defined for example.
And as I've said it forces the developer to do another catch block and
even extract the actual exception because it most cases (like the one
above) the JcrMappingException is just eating the initial exception.
JcrMappingException should have a value by itself - have exception
that actually belogn to the jcr-mapping functionality not be a
transporter for other exceptions.

-- 
Best regards,
 Costin                            mailto:costin.leau@gmail.com


Re: [jcr-mapping] exceptions

Posted by Christophe Lombart <ch...@gmail.com>.
On 10/3/05, Costin Leau <co...@gmail.com> wrote:
> Hello,
>
> another remark on the exceptions from jcr-mapping project. Why isn't
> there a base exception
Yes there is one : JcrMappingException but we have not yet defined the
exception hierarchy. I would like to minize the number of exception.

 and why java.lang.Exception is extended instead
> of the javax.jcr.RepositoryException?

It is a good suggestion

> As the jcr-mapping is based on a JCR implementation it should extend
> the JCR exception hierarchy. Right now the code executing with
> jcr-mapping has to do a:
>
> try
> {
>   .. some code
> } catch (RepositoryException re)
> {
>    // from work on the repository
> } catch (JcrMappingException jme)
> {
>   // from mapping code
> }
>

Well, the code is still under dev and maybe we have to review the
exception management but why the following code is not correct ?

 try
 {
       some code
 }
 catch (Exception e)
 {
       throw new JcrMappingException("exception message" , e);
 }