Good evening,
I think that this happens because the default error
handler is invoked (you haven't set yours), and its behavior is: do nothing.
To catch errors while parsing you need to install an error handler, the
samples available in the Xerces package should help you in doing so.
Hope this helps!
Roberto
Wijnand Suijlen wrote:
Hi all,
I have the the following program:
#include <iostream>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/PlatformUtils.hpp>
using namespace xercesc;
int main()
{
XMLPlatformUtils :: Initialize();
XercesDOMParser *parser = new XercesDOMParser;
try {
parser->parse("non existing file");
}
catch(...)
{
std::cout << "it threw an exception" << std::endl;
delete parser;
XMLPlatformUtils::Terminate();
return 0;
}
std:: cout << "no exception was thrown" << std::endl;
delete parser;
XMLPlatformUtils::Terminate();
return 0;
}
Since I don't have a file on my system which is called 'non existing
file', I expect that it would output 'it threw an exception', but it
doesn't: It outputs 'no exception was thrown'. To me this seems very
weird. Is this is a bug or a feature? How do I get to know whether the
file exists or not?
I am using gcc 4.2.1 with Xerces 2.8.
Thanks very much!
Wijnand