Properly report errors as errors.

RELNOTES: None
PiperOrigin-RevId: 172133468
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java b/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
index 3b7556b..249916a 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
@@ -237,7 +237,7 @@
   private static ProcessPackageDirectoryResult reportErrorAndReturn(
       String errorPrefix, Exception e, PathFragment rootRelativePath, EventHandler handler) {
     handler.handle(
-        Event.warn(errorPrefix + ", for " + rootRelativePath + ", skipping: " + e.getMessage()));
+        Event.error(errorPrefix + ", for " + rootRelativePath + ", skipping: " + e.getMessage()));
     return ProcessPackageDirectoryResult.EMPTY_RESULT;
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java
index fc83dfc..37a992d 100644
--- a/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java
+++ b/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java
@@ -13,8 +13,10 @@
 // limitations under the License.
 package com.google.devtools.build.lib.pkgcache;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.truth.Truth;
 import com.google.devtools.build.lib.clock.BlazeClock;
+import com.google.devtools.build.lib.events.EventKind;
 import com.google.devtools.build.lib.vfs.Dirent;
 import com.google.devtools.build.lib.vfs.FileStatus;
 import com.google.devtools.build.lib.vfs.FileSystem;
@@ -86,9 +88,15 @@
     this.transformer = createInconsistentFileStateTransformer("parent/badstat");
 
     // When we find all the targets beneath parent in keep_going mode, we get the valid target
-    // parent:parent, even though processing badstat threw an InconsistentFilesystemException.
+    // parent:parent, even though processing badstat threw an InconsistentFilesystemException,
     Truth.assertThat(parseListKeepGoing("//parent/...").getFirst())
         .containsExactlyElementsIn(labels("//parent:parent"));
+
+    // And the TargetPatternEvaluator reported the expected ERROR event to the handler.
+    assertContainsEvent(
+        "Failed to get information about path, for parent/badstat, skipping: Inconsistent "
+            + "filesystem operations",
+        ImmutableSet.of(EventKind.ERROR));
   }
 
   /**
@@ -109,9 +117,15 @@
     this.transformer = createBadDirectoryListingTransformer("parent/badstat");
 
     // When we find all the targets beneath parent in keep_going mode, we get the valid target
-    // parent:parent, even though processing badstat threw an InconsistentFilesystemException.
+    // parent:parent, even though processing badstat threw an IOException,
     Truth.assertThat(parseListKeepGoing("//parent/...").getFirst())
         .containsExactlyElementsIn(labels("//parent:parent"));
+
+    // And the TargetPatternEvaluator reported the expected ERROR event to the handler.
+    assertContainsEvent(
+        "Failed to list directory contents, for parent/badstat, skipping: Path ended in "
+            + "parent/badstat, so readdir failed",
+        ImmutableSet.of(EventKind.ERROR));
   }
 
   private Transformer createInconsistentFileStateTransformer(final String badPathSuffix) {