jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OAK-89) Improve exception handling
Date Tue, 08 May 2012 16:27:49 GMT

    [ https://issues.apache.org/jira/browse/OAK-89?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13270581#comment-13270581
] 

Jukka Zitting commented on OAK-89:
----------------------------------

bq. Why {{AbstractNameMapper.getJcrName()}} should throw a {{IllegalStateException}} here
is beyond me.

Here's how I'd define the error-handling for the NameMapper interface:

{code:java}
/**
 * Returns the Oak name for the given JCR name, or {@code null} if no
 * such mapping exists because the given JCR name contains an unknown
 * namespace URI or prefix, or is otherwise invalid.
 *
 * @param jcrName JCR name
 * @return Oak name, or {@code null}
 */
String getOakName(String jcrName);

/**
 * Returns the JCR name for the given Oak name. The given name is
 * expected to have come from a valid Oak repository that contains
 * only valid names with proper namespace mappings. If that's not
 * the case, either a programming error or a repository corruption
 * has occurred and an appropriate unchecked exception gets thrown.
 *
 * @param oakName Oak name
 * @return JCR name
 */
String getJcrName(String oakName);
{code}

Are there some cases that aren't covered by such a definition?
                
> Improve exception handling
> --------------------------
>
>                 Key: OAK-89
>                 URL: https://issues.apache.org/jira/browse/OAK-89
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core, jcr
>    Affects Versions: 0.2.1
>            Reporter: Michael Dürig
>         Attachments: OAK-89-2.patch, OAK-89.patch
>
>
> As discusses on the @oak-dev list [1] we need to improve the way exceptions are thrown
and handled. 
> I suggest to create a OakException which extends from RuntimeException and encapsulate
a RepositoryException into it. These exceptions can then be handled where appropriate. We
can the later turn this into a more sophisticated mechanism where the OakException is mapped
to a corresponding RepositoryException by an injected mapping (see Jukka's proposal in the
discussion).
> [1] http://markmail.org/message/t5czrpkvyamn7sym

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message