Raise error if we find an unknown type in native.rule().

Handle more types:

* Boolean
* TriState
* SkylarkValue (eg. FileSetEntry)
* skip Licenses, Distribs.

--
MOS_MIGRATED_REVID=112690550
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
index 6cbbf23..74a9f4c 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
@@ -198,17 +198,31 @@
     }
   }
 
-  private IllegalStateException badCallException(Location loc, Throwable e, Object... args) {
-    // If this happens, it's a bug in our code.
-    return new IllegalStateException(String.format("%s%s (%s)\n"
-            + "while calling %s with args %s\nJava parameter types: %s\nSkylark type checks: %s",
-            (loc == null) ? "" : loc + ": ",
-            e.getClass().getName(), e.getMessage(), this,
-            Arrays.asList(args),
-            Arrays.asList(invokeMethod.getParameterTypes()),
-            signature.getTypes()), e);
+  private static String stacktraceToString(StackTraceElement[] elts) {
+    StringBuilder b = new StringBuilder();
+    for (StackTraceElement e : elts) {
+      b.append(e.toString());
+      b.append("\n");
+    }
+    return b.toString();
   }
 
+  private IllegalStateException badCallException(Location loc, Throwable e, Object... args) {
+    // If this happens, it's a bug in our code.
+    return new IllegalStateException(
+        String.format(
+            "%s%s (%s)\n"
+                + "while calling %s with args %s\n"
+                + "Java parameter types: %s\nSkylark type checks: %s",
+            (loc == null) ? "" : loc + ": ",
+            Arrays.asList(args),
+            e.getClass().getName(),
+            stacktraceToString(e.getStackTrace()),
+            this,
+            Arrays.asList(invokeMethod.getParameterTypes()),
+            signature.getTypes()),
+        e);
+  }
 
   /** Configure the reflection mechanism */
   @Override