From 9c203cd2b4821ec377cb0dcfcfccd51fd9866211 Mon Sep 17 00:00:00 2001 From: titiger Date: Sat, 3 Dec 2016 01:23:35 +0100 Subject: [PATCH] Error messages for XML parse errors without stack And we validate closing tags too now --- source/shared_lib/sources/xml/xml_parser.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index 11676a4f..4832fac1 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -402,7 +402,7 @@ XmlNode *XmlIoRapid::load(const string &path, const std::map &map if(showPerfStats) printf("In [%s::%s Line: %d] took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis()); xml_document<> doc; - doc.parse(&buffer.front()); + doc.parse(&buffer.front()); if(showPerfStats) printf("In [%s::%s Line: %d] took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis()); @@ -416,9 +416,14 @@ XmlNode *XmlIoRapid::load(const string &path, const std::map &map } #endif } + catch(parse_error& ex) { +// char szBuf[8096]=""; +// snprintf(szBuf,8096,"%s",ex.where()); + throw megaglest_runtime_error("Error loading XML: "+ path + "\nMessage: " + ex.what() ,true); + } catch(megaglest_runtime_error& ex) { - throw megaglest_runtime_error("Error loading XML: "+ path + "\nMessage: " + ex.what(),!ex.wantStackTrace() ); - } + throw megaglest_runtime_error("Error loading XML: "+ path + "\nMessage: " + ex.what(),!ex.wantStackTrace() ); + } catch(const exception &ex) { char szBuf[8096]="";