You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Ravi_Jain <Ra...@satyam.com> on 2002/04/11 14:49:45 UTC

Unable to Catch SAX Exception.

Hi All

I am parsing a file using 
.....
parser->parseFirst(filename,toFill);
....
I am able to parse and retrive data when the file exist.
In case of nonexistence of the file, no error is reported and whole code is
ignored.
Please let me know so as to how can I catch this problem.

Thanks in Advance
With Warm Regards




Ravi Jain

************************************************************************** 
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Unable to Catch SAX Exception.

Posted by Martin Kalen <ma...@todaysystems.com.au>.
> I am parsing a file using 
> .....
> parser->parseFirst(filename,toFill);
> ....
> I am able to parse and retrive data when the file exist.
> In case of nonexistence of the file, no error is reported and whole code is
> ignored.

You must also catch any XMLException, take a look a this snippet:

try
{
    //
    bool gotMore = parser->parseFirst(*input, token);
    //
}
catch (const SAXException& excToCatch)
    //
catch (const XMLException& excToCatch)
    //
catch (...)
    //


If running this with a non-existing primary document entity, you will catch an exception of class XMLException.
excToCatch.getErrorType() == XMLErrorReporter::ErrType_Fatal
excToCatch.getMessage() == "The primary document entity could not be opened. Id=" (followed by your input buffer's id)

Regards,
 Martin