aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax
diff options
context:
space:
mode:
authorGravatar Laurent Le Brun <laurentlb@google.com>2017-03-02 14:12:53 +0000
committerGravatar Yue Gan <yueg@google.com>2017-03-03 10:35:18 +0000
commit83514648f2e4e63dcd039e976f3b5d47552e0383 (patch)
treee14c5bed02180977a1eefb61cfe4f5f3ef30be59 /src/main/java/com/google/devtools/build/lib/syntax
parent69a127b8f4e353ecb163688ed3271fb47e0f385d (diff)
Improve error message for the 'in' operator.
In particular, display the type that was passed as argument. -- PiperOrigin-RevId: 148995695 MOS_MIGRATED_REVID=148995695
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java
index 0da5e5c4fb..e6d37905c5 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java
@@ -77,11 +77,18 @@ public final class BinaryOperatorExpression extends Expression {
return ((String) rval).contains((String) lval);
} else {
throw new EvalException(
- location, "in operator only works on strings if the left operand is also a string");
+ location,
+ "'in <string>' requires string as left operand, not '"
+ + EvalUtils.getDataTypeName(lval)
+ + "'");
}
} else {
throw new EvalException(
- location, "in operator only works on lists, tuples, sets, dicts and strings");
+ location,
+ "argument of type '"
+ + EvalUtils.getDataTypeName(rval)
+ + "' is not iterable. "
+ + "in operator only works on lists, tuples, dicts and strings.");
}
}