summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-08-20 14:13:12 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-08-20 14:13:12 +0000
commit54539faca674409d91766034804677546c468c39 (patch)
tree574e2bf1ec8a104fa2739c09ba95a3ec12a9427b /document
parent2d68435a3261b3a70c472ab5138d39a5074cf9d5 (diff)
Expect and handle field not found exception.
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/fieldset/fieldsetrepo.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/document/src/vespa/document/fieldset/fieldsetrepo.cpp b/document/src/vespa/document/fieldset/fieldsetrepo.cpp
index 5bde291c8dd..962e2efd6d0 100644
--- a/document/src/vespa/document/fieldset/fieldsetrepo.cpp
+++ b/document/src/vespa/document/fieldset/fieldsetrepo.cpp
@@ -5,8 +5,12 @@
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/document/repo/documenttyperepo.h>
+#include <vespa/document/base/exceptions.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
+#include <vespa/log/log.h>
+LOG_SETUP(".document.fieldset.fieldsetrepo");
+
using vespalib::StringTokenizer;
namespace document {
@@ -124,7 +128,13 @@ FieldSetRepo::configureDocumentType(const DocumentType & documentType) {
for (const auto & entry : documentType.getFieldSets()) {
vespalib::string fieldSetName(documentType.getName());
fieldSetName.append(':').append(entry.first);
- _configuredFieldSets[fieldSetName] = parse(_doumentTyperepo, fieldSetName);
+ try {
+ auto fieldset = parse(_doumentTyperepo, fieldSetName);
+ _configuredFieldSets[fieldSetName] = std::move(fieldset);
+ } catch (const FieldNotFoundException & ex) {
+ LOG(warning, "Did not find field %s in configured fieldset %s, will default to NO fields.",ex.getFieldName().c_str(), fieldSetName.c_str());
+ _configuredFieldSets[fieldSetName] = std::make_shared<NoFields>();
+ }
}
}
FieldSet::SP
@@ -133,7 +143,12 @@ FieldSetRepo::getFieldSet(vespalib::stringref fieldSetString) const {
if (found != _configuredFieldSets.end()) {
return found->second;
}
- return parse(_doumentTyperepo, fieldSetString);
+ try {
+ return parse(_doumentTyperepo, fieldSetString);
+ } catch (const FieldNotFoundException & ex) {
+ LOG(warning, "Did not find field %s in configured fieldset %s, will default to NO fields.",ex.getFieldName().c_str(), vespalib::string(fieldSetString).c_str());
+ return std::make_shared<NoFields>();
+ }
}
}