aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-08-18 11:15:50 +0200
committerJon Bratseth <bratseth@gmail.com>2020-08-18 11:15:50 +0200
commitc30bbdb0fa50cedc56eec71feeadc969ba5a3edf (patch)
tree6935b4d042618900ee0f7fd291c14ed55ae06cf8 /container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
parent529694a88d48270298171fdcb87d1439f183202b (diff)
Skip logging only for IllegalInputException
- Add IllegalInputException to signal cases where we know the exception is caused by illegal input received from the requestor. - Only skip logging for IllegalInputException instead of the superclass IllegalArgumentException as that is also used to signal illegal arguments to methods due to bugs which are otherwise hard to debug. - Throw IllegalInputException rather than IllegalArgumentException where appropriate. - Deprecated QueryException as it was only used to be able to separate between query string and query parameter exceptions, and not doing that consistently, and is in a package we don't want more use of. - Clean up some cases where the wrong exception was thrown.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
index d199ee44c9c..41272d695ac 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
@@ -2,6 +2,7 @@
package com.yahoo.search.query.profile;
import com.yahoo.collections.Pair;
+import com.yahoo.processing.IllegalInputException;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.processing.request.properties.PropertyMap;
import com.yahoo.protect.Validator;
@@ -107,7 +108,7 @@ public class QueryProfileProperties extends Properties {
String localName = name.get(i);
FieldDescription fieldDescription = type.getField(localName);
if (fieldDescription == null && type.isStrict())
- throw new IllegalArgumentException("'" + localName + "' is not declared in " + type + ", and the type is strict");
+ throw new IllegalInputException("'" + localName + "' is not declared in " + type + ", and the type is strict");
// TODO: In addition to strictness, check legality along the way
@@ -115,7 +116,7 @@ public class QueryProfileProperties extends Properties {
if (i == name.size() - 1) { // at the end of the path, check the assignment type
value = fieldDescription.getType().convertFrom(value, profile.getRegistry());
if (value == null)
- throw new IllegalArgumentException("'" + value + "' is not a " +
+ throw new IllegalInputException("'" + value + "' is not a " +
fieldDescription.getType().toInstanceDescription());
}
else if (fieldDescription.getType() instanceof QueryProfileFieldType) {
@@ -129,12 +130,12 @@ public class QueryProfileProperties extends Properties {
if (value instanceof String && value.toString().startsWith("ref:")) {
if (profile.getRegistry() == null)
- throw new IllegalArgumentException("Runtime query profile references does not work when the " +
+ throw new IllegalInputException("Runtime query profile references does not work when the " +
"QueryProfileProperties are constructed without a registry");
String queryProfileId = value.toString().substring(4);
value = profile.getRegistry().findQueryProfile(queryProfileId);
if (value == null)
- throw new IllegalArgumentException("Query profile '" + queryProfileId + "' is not found");
+ throw new IllegalInputException("Query profile '" + queryProfileId + "' is not found");
}
if (value instanceof CompiledQueryProfile) { // this will be due to one of the two clauses above
@@ -149,7 +150,7 @@ public class QueryProfileProperties extends Properties {
}
}
catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("Could not set '" + name + "' to '" + value + "'", e);
+ throw new IllegalInputException("Could not set '" + name + "' to '" + value + "'", e);
}
}