Have StarlarkNativeModule#glob handle IllegalArgumentException.

A recent change to MethodDescriptor#call removed the handling of Throwablbe there, so therefore it's necessary to do something somewhere.

RELNOTES: None
PiperOrigin-RevId: 255619205
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SkylarkNativeModule.java b/src/main/java/com/google/devtools/build/lib/packages/SkylarkNativeModule.java
index 6a8eef1..310b667 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SkylarkNativeModule.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SkylarkNativeModule.java
@@ -42,8 +42,12 @@
       Environment env)
       throws EvalException, ConversionException, InterruptedException {
     SkylarkUtils.checkLoadingPhase(env, "native.glob", ast.getLocation());
-    return PackageFactory.callGlob(
-        null, include, exclude, excludeDirectories != 0, allowEmpty, ast, env);
+    try {
+      return PackageFactory.callGlob(
+          null, include, exclude, excludeDirectories != 0, allowEmpty, ast, env);
+    } catch (IllegalArgumentException e) {
+      throw new EvalException(ast.getLocation(), "illegal argument in call to glob", e);
+    }
   }
 
   @Override
diff --git a/src/test/shell/integration/loading_phase_test.sh b/src/test/shell/integration/loading_phase_test.sh
index 91c9070..5387f2d 100755
--- a/src/test/shell/integration/loading_phase_test.sh
+++ b/src/test/shell/integration/loading_phase_test.sh
@@ -390,4 +390,22 @@
   done
 }
 
+function test_illegal_glob_exclude_pattern_in_bzl() {
+  mkdir badglob-bzl || fail "mkdir failed"
+  cat > badglob-bzl/BUILD <<EOF
+load("//badglob-bzl:badglob.bzl", "f")
+f()
+EOF
+  cat > badglob-bzl/badglob.bzl  <<EOF
+def f():
+  return native.glob(include = ["BUILD"], exclude = ["a/**b/c"])
+EOF
+
+  bazel query //badglob-bzl:BUILD >& "$TEST_log" && fail "Expected failure"
+  local exit_code=$?
+  assert_equals 7 "$exit_code"
+  expect_log "illegal argument in call to glob"
+  expect_not_log "IllegalArgumentException"
+}
+
 run_suite "Integration tests of ${PRODUCT_NAME} using loading/analysis phases."