I'm writing a small wrapper around libxml2 in C++, and I'm trying to work out how to handle errors. For now, let's say I just want to print them out. Here's what I've got at present:
My error handling function:
void foo(void *ctx, const char *msg, ...) {
cout << msg << endl;
return;
}
Initialised like this:
xmlGenericErrorFunc handler = (xmlGenericErrorFunc)foo;
initGenericErrorDefaultFunc(&handler);
However, if I parse a bad XPath, I get this output:
%s
Without the error handling code, I get this:
XPath error : Invalid expression //.@foobar ^
Obviously eventually my error handling will do more than just print out the error message (it'll log it to a database or something), but for now - how can I get that error string?