You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Scott Sanders <ss...@nextance.com> on 2002/02/20 20:51:16 UTC

RE: Digester parsing user question

As far as I know the code, all SAXExceptions are bubbled straight to the
user (you), Digester 'swallows' nothing.

Typically with a SAX parser, you get the first exception and then it
fails.  It is not like a compiler, which keeps reporting errors, so you
should be able to catch the first and only exception that the parser
spits out.

Cheers,
Scott Sanders

> -----Original Message-----
> From: Kyle Robinson [mailto:KRobinson@pangaeainc.com] 
> Sent: Wednesday, February 20, 2002 11:58 AM
> To: 'commons-dev@jakarta.apache.org'
> Subject: Digester parsing user question
> 
> 
> When I pass a badly formed xml document into my 
> digester.parse() method it seems to be handling an 
> SAXParseExceptions internally.  How can I catch the 
> SAXParseExceptions myself?  (For example: I want to add the
> exception.getMessage() to a Vector of Strings) 
>  
> Any help would be appreciated, thanks.
>  
> Kyle Robinson
> Systems Consultant
> Pangaea Systems Inc.
> (250) 360-0111
>  
> 

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


Re: Digester parsing user question

Posted by Richard Frazer <ri...@haht.com>.
The digester implements ErrorHandler and is the default error handler 
for the SAX Parser.  The way it handles the "error" method is to just 
print out a message and continue along.  If you want to be able to do 
your own thing, you must implement the ErrorHandler interface yourself 
and call digester.setErrorHandler().

Ex.

        digester = new Digester();
        digester.setErrorHandler( new LittleErrorHandler() );

Where LittleErrorHandler is defined like this:


    private class LittleErrorHandler implements ErrorHandler
    {
        public void warning(SAXParseException e)
            throws SAXException
        {
            return;
        }

        public void error(SAXParseException e)
            throws SAXException
        {
            throw e;
        }

        public void fatalError(SAXParseException e)
            throws SAXException
        {
            throw e;
        }
    }


Scott Sanders wrote:

>As far as I know the code, all SAXExceptions are bubbled straight to the
>user (you), Digester 'swallows' nothing.
>
>Typically with a SAX parser, you get the first exception and then it
>fails.  It is not like a compiler, which keeps reporting errors, so you
>should be able to catch the first and only exception that the parser
>spits out.
>
>Cheers,
>Scott Sanders
>
>>-----Original Message-----
>>From: Kyle Robinson [mailto:KRobinson@pangaeainc.com] 
>>Sent: Wednesday, February 20, 2002 11:58 AM
>>To: 'commons-dev@jakarta.apache.org'
>>Subject: Digester parsing user question
>>
>>
>>When I pass a badly formed xml document into my 
>>digester.parse() method it seems to be handling an 
>>SAXParseExceptions internally.  How can I catch the 
>>SAXParseExceptions myself?  (For example: I want to add the
>>exception.getMessage() to a Vector of Strings) 
>> 
>>Any help would be appreciated, thanks.
>> 
>>Kyle Robinson
>>Systems Consultant
>>Pangaea Systems Inc.
>>(250) 360-0111
>> 
>>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>



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