From afd223129824babe74399cd340ca7838d2910863 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 17 Feb 2015 19:37:45 +0100 Subject: Improved error messages in case no primitive field is present, but data is given --- src/core/parser/stack/DocumentHandler.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/core/parser/stack/DocumentHandler.cpp') diff --git a/src/core/parser/stack/DocumentHandler.cpp b/src/core/parser/stack/DocumentHandler.cpp index 49bf26b..7fd2d8c 100644 --- a/src/core/parser/stack/DocumentHandler.cpp +++ b/src/core/parser/stack/DocumentHandler.cpp @@ -383,16 +383,24 @@ bool DocumentChildHandler::data(Variant &data) } // No field was found that might take the data -- dump the error messages - // from the loggers - logger().error("Could not read data with any of the possible fields:", - SourceLocation{}, MessageMode::NO_CONTEXT); - size_t f = 0; - for (auto field : defaultFields) { - logger().note(std::string("Field ") + Utils::join(field->path(), ".") + - std::string(":"), - SourceLocation{}, MessageMode::NO_CONTEXT); - forks[f].commit(); - f++; + // from the loggers -- or, if there were no primitive fields, clearly state + // this fact + if (defaultFields.empty()) { + logger().error("Got data, but structure \"" + name() + + "\" does not have any primitive field", + data); + } else { + logger().error("Could not read data with any of the possible fields:", + data); + size_t f = 0; + for (auto field : defaultFields) { + logger().note(std::string("Field ") + + Utils::join(field->path(), ".") + + std::string(":"), + SourceLocation{}, MessageMode::NO_CONTEXT); + forks[f].commit(); + f++; + } } return false; } @@ -417,4 +425,4 @@ namespace RttiTypes { const Rtti DocumentField = RttiBuilder( "DocumentField").parent(&Node); } -} \ No newline at end of file +} -- cgit v1.2.3