diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-08-07 12:56:39 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-08-07 12:56:39 +0000 |
commit | 2da5042dbe3fb69fc2688958bad242bb8695cd2f (patch) | |
tree | 13d9405b823e898b834ec2f21b28ca090af7ef17 | |
parent | 0d189d33ca259dd191c6c14aa52027493b4746b8 (diff) |
better error messages
-rw-r--r-- | searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp | 8 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp b/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp index 6628a889903..f36c1dbfdaa 100644 --- a/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp @@ -41,6 +41,9 @@ TensorFromLabelsBlueprint::setup(const search::fef::IIndexEnvironment &env, // _params[0] = source ('attribute(name)' OR 'query(param)'); // _params[1] = dimension (optional); bool validSource = extractSource(params[0].getValue()); + if (! validSource) { + return fail("invalid source: '%s'", params[0].getValue().c_str()); + } if (params.size() == 2) { _dimension = params[1].getValue(); } else { @@ -48,10 +51,13 @@ TensorFromLabelsBlueprint::setup(const search::fef::IIndexEnvironment &env, } auto vt = ValueType::make_type(CellType::DOUBLE, {{_dimension}}); _valueType = ValueType::from_spec(vt.to_spec()); + if (_valueType.is_error()) { + return fail("invalid dimension name: '%s'", _dimension.c_str()); + } describeOutput("tensor", "The tensor created from the given source (attribute field or query parameter)", FeatureType::object(_valueType)); - return validSource && ! _valueType.is_error(); + return true; } namespace { diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp b/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp index c635675b216..312f9ee2bc6 100644 --- a/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp @@ -54,6 +54,9 @@ TensorFromWeightedSetBlueprint::setup(const search::fef::IIndexEnvironment &env, // _params[0] = source ('attribute(name)' OR 'query(param)'); // _params[1] = dimension (optional); bool validSource = extractSource(params[0].getValue()); + if (! validSource) { + return fail("invalid source: '%s'", params[0].getValue().c_str()); + } if (params.size() == 2) { _dimension = params[1].getValue(); } else { @@ -61,10 +64,13 @@ TensorFromWeightedSetBlueprint::setup(const search::fef::IIndexEnvironment &env, } auto vt = ValueType::make_type(CellType::DOUBLE, {{_dimension}}); _valueType = ValueType::from_spec(vt.to_spec()); + if (_valueType.is_error()) { + return fail("invalid dimension name: '%s'", _dimension.c_str()); + } describeOutput("tensor", "The tensor created from the given weighted set source (attribute field or query parameter)", FeatureType::object(_valueType)); - return validSource && ! _valueType.is_error(); + return true; } namespace { |