summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2018-08-06 12:38:06 +0000
committerTor Egge <Tor.Egge@oath.com>2018-08-06 12:38:06 +0000
commit32ce926d8dae6c77446810b26ffb754e81ef9b32 (patch)
tree3faed6f7007b8a96b3cef53eabb7807120f663db /document
parent4555f4d71dcb13d4fb7bfb361b2d04bde9f12e73 (diff)
Move try/catch statements to parseDocumentSelection helper function.
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/update/fieldpathupdate.cpp28
1 files changed, 15 insertions, 13 deletions
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 <vespa/document/datatype/datatype.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/document/fieldvalue/iteratorhandler.h>
+#include <vespa/document/select/constant.h>
#include <vespa/document/select/parser.h>
#include <vespa/document/select/parsing_failed_exception.h>
#include <vespa/document/util/serializableexceptions.h>
@@ -28,8 +29,13 @@ std::unique_ptr<select::Node>
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<select::Constant>(false);
+ }
}
} // namespace
@@ -66,18 +72,14 @@ FieldPathUpdate::applyTo(Document& doc) const
if (_originalWhereClause.empty()) {
doc.iterateNested(path, *handler);
} else {
- try {
- std::unique_ptr<select::Node> 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<select::Node> 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());
}
}
}