Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 5c1d873

Browse files
committed
Merge pull request #292 from dawagner/better-libxml2-error-messages
Print the file and line number context in libxml2 error messages
2 parents d1c6bf3 + 1015c96 commit 5c1d873

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

xmlserializer/XmlSerializingContext.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,10 @@ void CXmlSerializingContext::appendLineToError(const std::string& strAppend)
5757
void CXmlSerializingContext::structuredErrorHandler(void* userData, xmlErrorPtr error)
5858
{
5959
CXmlSerializingContext *self = static_cast<CXmlSerializingContext *>(userData);
60-
self->_strXmlError += error->message;
60+
61+
std::string filename = (error->file != NULL) ? error->file : "(user input)";
62+
// xmlErrorPtr->int2 contains the column; see xmlerror.h
63+
self->_strXmlError += filename + ":" +
64+
std::to_string(error->line) + ":" + std::to_string(error->int2) + ": " +
65+
error->message;
6166
}

0 commit comments

Comments
 (0)