tinyxml2
tinyxml2 copied to clipboard
XMLDocument::ErrorStr() returns empty string in some cases
XMLDocument::SetError() implementation creates a "long form" error description only if format is provided.
However, in about dozen cases SetError is called with format set to 0 (example), rendering ErrorStr() & PrintError() useless.
Is it intentional? It feels like it was supposed to be something like this instead:
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 04cf697..d0a66ee 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -2305,20 +2305,20 @@ void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ...
_errorLineNum = lineNum;
_errorStr.Reset();
- if (format) {
size_t BUFFER_SIZE = 1000;
char* buffer = new char[BUFFER_SIZE];
TIXML_SNPRINTF(buffer, BUFFER_SIZE, "Error=%s ErrorID=%d (0x%x) Line number=%d: ", ErrorIDToName(error), int(error), int(error), lineNum);
size_t len = strlen(buffer);
+ if (format) {
va_list va;
va_start( va, format );
TIXML_VSNPRINTF( buffer + len, BUFFER_SIZE - len, format, va );
va_end( va );
+ }
_errorStr.SetStr(buffer);
delete [] buffer;
- }
}
- i.e. always create a "basic" description and append some custom data, if provided.
Thanks.
Good point. Marking enhancement.
Thanks. Related question: after aa18839 error messages are less detailed - the xml content isn't displayed anymore here and in some other places. Is it intentional?
Possible I missed some. Re-opening to check.