G
Greg O'Rawe
Hi,
I am using the Xerces C++ parser API (2.3.0) on Solaris 2.8 and am getting a
problem if I try to parse a file which does not exist.
Here's the code:
XercesDOMParser *parser = new XercesDOMParser;
try
{
parser->parse(file.data());
}
catch (const XMLException& xmlException)
{
logError("ConfigFileReader::ReadGeneralConfigFile An error occurred
attempting to parse XML file %s, cause = $s", file,
xmlException.getMessage());
return false;
}
catch (const DOMException& domException)
{
logError("ConfigFileReader::ReadGeneralConfigFile An error occurred
attempting to parse DOM file %s, code = $s", file, domException.code);
return false;
}
catch (...)
{
logError("ConfigFileReader::ReadGeneralConfigFile An unknown error
occurred attempting to parse XML file %s", file);
return false;
}
Everything is fine if the XML file exists and it is parsed without problem.
However if the file does not exist an exception is not thrown and the
program continues to try and traverse the doucment tree (which does not
exist of course). Even the (...) catch-all exception is not run.
Is there anything I have missed here? I can't see anything from the sample
Xerces stuff and the API documentation.
Many thanks
Greg
I am using the Xerces C++ parser API (2.3.0) on Solaris 2.8 and am getting a
problem if I try to parse a file which does not exist.
Here's the code:
XercesDOMParser *parser = new XercesDOMParser;
try
{
parser->parse(file.data());
}
catch (const XMLException& xmlException)
{
logError("ConfigFileReader::ReadGeneralConfigFile An error occurred
attempting to parse XML file %s, cause = $s", file,
xmlException.getMessage());
return false;
}
catch (const DOMException& domException)
{
logError("ConfigFileReader::ReadGeneralConfigFile An error occurred
attempting to parse DOM file %s, code = $s", file, domException.code);
return false;
}
catch (...)
{
logError("ConfigFileReader::ReadGeneralConfigFile An unknown error
occurred attempting to parse XML file %s", file);
return false;
}
Everything is fine if the XML file exists and it is parsed without problem.
However if the file does not exist an exception is not thrown and the
program continues to try and traverse the doucment tree (which does not
exist of course). Even the (...) catch-all exception is not run.
Is there anything I have missed here? I can't see anything from the sample
Xerces stuff and the API documentation.
Many thanks
Greg