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

Commit

Permalink
Merge pull request #292 from dawagner/better-libxml2-error-messages
Browse files Browse the repository at this point in the history
Print the file and line number context in libxml2 error messages
  • Loading branch information
dawagner committed Oct 20, 2015
2 parents d1c6bf3 + 1015c96 commit 5c1d873
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xmlserializer/XmlSerializingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ void CXmlSerializingContext::appendLineToError(const std::string& strAppend)
void CXmlSerializingContext::structuredErrorHandler(void* userData, xmlErrorPtr error)
{
CXmlSerializingContext *self = static_cast<CXmlSerializingContext *>(userData);
self->_strXmlError += error->message;

std::string filename = (error->file != NULL) ? error->file : "(user input)";
// xmlErrorPtr->int2 contains the column; see xmlerror.h
self->_strXmlError += filename + ":" +
std::to_string(error->line) + ":" + std::to_string(error->int2) + ": " +
error->message;
}

0 comments on commit 5c1d873

Please sign in to comment.