[jira] [Commented] (DIGESTER-171) Add DefaultThrowingErrorHandler to Digester API.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DIGESTER-171) Add DefaultThrowingErrorHandler to Digester API.

ASF GitHub Bot (Jira)

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

Sebb commented on DIGESTER-171:
-------------------------------

bq. * When adding new classes, it is a good practice adding the @since javadoc tag.

At the time a patch is submitted, the next version number might not have been decided.
Rather than use a possibly incorrect version number, one solution would be to add {{@since TODO}} (or similar)
This would remind the developer/committer that the version needs to documented.

[Patches containing new methods and fields should also ideally have the {{@since}} tags.]
               

> Add DefaultThrowingErrorHandler to Digester API.
> ------------------------------------------------
>
>                 Key: DIGESTER-171
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-171
>             Project: Commons Digester
>          Issue Type: Improvement
>    Affects Versions: 3.2
>            Reporter: Nick Williams
>            Assignee: Simone Tripodi
>            Priority: Minor
>             Fix For: 3.3
>
>         Attachments: DIGESTER-171.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The current default error handling behavior is for the SAX parses to NOT throw exceptions when they occur, but instead to log them to stderr. This is fine and I am not suggesting that be changed. However, there is a wiki article (http://wiki.apache.org/commons/Digester/FAQ) that describes the common task of implementing an error handler that throws encountered errors.
> If this is so common, it would seem that including such an error handler in the API would be a very convenient thing to do.
> I propose that the following class be added to the digester to make it convenient for anyone to turn on this behavior:
> {code}package org.apache.commons.digester3;
> import org.xml.sax.ErrorHandler;
> import org.xml.sax.SAXException;
> import org.xml.sax.SAXParseException;
> public class DefaultThrowingErrorHandler implements ErrorHandler
> {
>     @Override
>     public void warning(SAXParseException e) throws SAXException
>     {
>         throw e;
>     }
>     @Override
>     public void error(SAXParseException e) throws SAXException
>     {
>         throw e;
>     }
>     @Override
>     public void fatalError(SAXParseException e) throws SAXException
>     {
>         throw e;
>     }
> }{code}
> Furthermore, I propose that the DigesterLoader and Digester classes have setThrowEncounteredSAXErrors(boolean) methods that set the error handler to the DefaultThrowingErrorHandler..

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira