Uploaded image for project: 'Commons Digester'
  1. Commons Digester
  2. DIGESTER-171

Add DefaultThrowingErrorHandler to Digester API.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.2
    • 3.3
    • None

    Description

      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:

      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;
          }
      }

      Furthermore, I propose that the DigesterLoader and Digester classes have setThrowEncounteredSAXErrors(boolean) methods that set the error handler to the DefaultThrowingErrorHandler..

      Attachments

        1. DIGESTER-171.patch
          3 kB
          Ivan Diana

        Activity

          People

            simone.tripodi Simone Tripodi
            beamerblvd Nick Williams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified