From 32ce926d8dae6c77446810b26ffb754e81ef9b32 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Mon, 6 Aug 2018 12:38:06 +0000 Subject: Move try/catch statements to parseDocumentSelection helper function. --- .../src/vespa/document/update/fieldpathupdate.cpp | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'document') diff --git a/document/src/vespa/document/update/fieldpathupdate.cpp b/document/src/vespa/document/update/fieldpathupdate.cpp index 1af648d343e..fa7a8b38aba 100644 --- a/document/src/vespa/document/update/fieldpathupdate.cpp +++ b/document/src/vespa/document/update/fieldpathupdate.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -28,8 +29,13 @@ std::unique_ptr parseDocumentSelection(vespalib::stringref query, const DocumentTypeRepo& repo) { BucketIdFactory factory; - select::Parser parser(repo, factory); - return parser.parse(query); + try { + select::Parser parser(repo, factory); + return parser.parse(query); + } catch (const ParsingFailedException &e) { + LOG(warning, "Failed to parse selection for field path update: %s", e.getMessage().c_str()); + return std::make_unique(false); + } } } // namespace @@ -66,18 +72,14 @@ FieldPathUpdate::applyTo(Document& doc) const if (_originalWhereClause.empty()) { doc.iterateNested(path, *handler); } else { - try { - std::unique_ptr whereClause = parseDocumentSelection(_originalWhereClause, *doc.getRepo()); - select::ResultList results = whereClause->contains(doc); - for (select::ResultList::const_iterator i = results.begin(); i != results.end(); ++i) { - LOG(spam, "vars = %s", handler->getVariables().toString().c_str()); - if (*i->second == select::Result::True) { - handler->setVariables(i->first); - doc.iterateNested(path, *handler); - } + std::unique_ptr whereClause = parseDocumentSelection(_originalWhereClause, *doc.getRepo()); + select::ResultList results = whereClause->contains(doc); + for (select::ResultList::const_iterator i = results.begin(); i != results.end(); ++i) { + LOG(spam, "vars = %s", handler->getVariables().toString().c_str()); + if (*i->second == select::Result::True) { + handler->setVariables(i->first); + doc.iterateNested(path, *handler); } - } catch (const ParsingFailedException &e) { - LOG(warning, "Failed to parse selection for field path update: %s", e.getMessage().c_str()); } } } -- cgit v1.2.3