You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by Mike Gratton <mi...@vee.net> on 2002/02/21 15:10:58 UTC
SAXEventGenerator hiding exceptions
Guys,
When calling getContentAsSAX(), any exceptions thrown by the
ContentHandler passed to that method are silently dropped by
SAXEventGenerator. This causes no end of frustration trying to track
down errors when processing XML content using SAX.
The problem with SAXEventGenerator the start() method. It catches all
exceptions and simply returns false if an exception is thrown.
Can I propose removing start() then renaming processDocument() to
start(), as per the attached patch? This means any SAXExceptions thrown
will at least cause a XMLDBException to be thrown, and make debugging
much easier.
If there's no objections, can someone check the patch in for me?
Cheers,
Mike.
--
Mike Gratton <mi...@vee.net>
"Every motive escalate."
Blatant self-promotion: <http://web.vee.net/>
Re: SAXEventGenerator hiding exceptions
Posted by Mike Gratton <mi...@vee.net>.
Kimbro Staken wrote:
> Looks ok to me, SAXEventGenerator is used by IndexManager too but it doesn'
> t bother with the return value anyway.
>
Thanks for committing that (and the NodeImpl patch).
The situation it better now, but given the the XMLDBException class has
no notion of a "cause" or "nested" Throwable[0], any SAXExceptions
thrown still can't be examined by the client API's user.
As a workaround in my local tree, I've moved the call to
org.apache.xindice.Debug.printStackTrace() that was in
SAXEventGenerator.start() to XMLResourceImpl, so any SAXExceptions will
still at least get dumped to stdout (or where ever the Debug class is
pointing to at the time).
Tiny patch attached. This may want to make it's way into the tree, at
least until a better solution is found.
Mike.
[0] - does anyone know if this limitation is going to get fixed in a
latter release of the XMLDB API?
--
Mike Gratton <mi...@vee.net>
"Every motive escalate."
Blatant self-promotion: <http://web.vee.net/>
Re: SAXEventGenerator hiding exceptions
Posted by Kimbro Staken <ks...@xmldatabases.org>.
Looks ok to me, SAXEventGenerator is used by IndexManager too but it doesn'
t bother with the return value anyway.
Thanks
On Thursday, February 21, 2002, at 07:10 AM, Mike Gratton wrote:
>
> Guys,
>
> When calling getContentAsSAX(), any exceptions thrown by the
> ContentHandler passed to that method are silently dropped by
> SAXEventGenerator. This causes no end of frustration trying to track down
> errors when processing XML content using SAX.
>
> The problem with SAXEventGenerator the start() method. It catches all
> exceptions and simply returns false if an exception is thrown.
>
> Can I propose removing start() then renaming processDocument() to
> start(), as per the attached patch? This means any SAXExceptions thrown
> will at least cause a XMLDBException to be thrown, and make debugging
> much easier.
>
> If there's no objections, can someone check the patch in for me?
>
> Cheers,
> Mike.
>
> -- Mike Gratton <mi...@vee.net>
> "Every motive escalate."
> Blatant self-promotion: <http://web.vee.net/>
> Index: java/src/org/apache/xindice/xml/sax/SAXEventGenerator.java
> ===================================================================
> RCS file: /home/cvspublic/xml-xindice/java/src/org/apache/xindice/xml/sax/
> SAXEventGenerator.java,v
> retrieving revision 1.3
> diff -u -r1.3 SAXEventGenerator.java
> --- java/src/org/apache/xindice/xml/sax/SAXEventGenerator.java 6 Jan 2002
> 18:10:17 -0000 1.3
> +++ java/src/org/apache/xindice/xml/sax/SAXEventGenerator.java 21 Feb 2002
> 14:11:31 -0000
> @@ -302,7 +302,7 @@
> return !interrupt;
> }
>
> - public boolean processDocument() throws IOException, SAXException {
> + public boolean start() throws IOException, SAXException {
> if ( comp != null ) {
> comp.symbols(symbols);
> comp.dataBytes(data);
> @@ -312,16 +312,6 @@
> if ( result )
> content.endDocument();
> return result;
> - }
> -
> - public boolean start() {
> - try {
> - return processDocument();
> - }
> - catch ( Exception e ) {
> - org.apache.xindice.Debug.printStackTrace(e);
> - return false;
> - }
> }
>
> public void stop() {
>
Kimbro Staken - http://www.kstaken.org - http://www.xmldatabases.org
Apache Xindice native XML database http://xml.apache.org
XML:DB Initiative http://www.xmldb.org
Senior Technologist (Your company name here)