Skip to content

Commit 388d87d

Browse files
NathanielVolfangojenkins
authored andcommitted
QPR-12411 better error message for xml parser errors
1 parent 32be158 commit 388d87d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

OREData/ored/utilities/xmlutils.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <boost/lexical_cast.hpp>
3030
#include <boost/algorithm/string/join.hpp>
31+
#include <boost/algorithm/string/erase.hpp>
3132

3233
// we only want to include these here.
3334
#if defined(__clang__)
@@ -62,9 +63,10 @@ namespace {
6263
// handle rapid xml parser errors
6364

6465
void handle_rapidxml_parse_error(const rapidxml::parse_error& e) {
65-
// limit to first 30 chars.
66-
string where(e.where<char>(), std::min<std::size_t>(strlen(e.where<char>()), 30));
67-
QL_FAIL("RapidXML Parse Error : " << e.what() << ". where=" << where);
66+
string where = e.where<char>();
67+
boost::erase_all(where, "\n");
68+
boost::erase_all(where, "\r");
69+
QL_FAIL("RapidXML Parse Error (" << e.what() << ") at '" << where.substr(0, 400) << "'");
6870
}
6971

7072

0 commit comments

Comments
 (0)