Improve error reporting from RecursivePackageProviderBackedTargetPatternResolver#bulkGetTargetsInPackage by checking if they are in error first.
@@ -141,6 +141,14 @@ public final class RecursivePackageProviderBackedTargetPatternResolver
rulesOnly ? FilteringPolicies.and(FilteringPolicies.RULES_ONLY, policy) : policy;
try {
Package pkg = getPackage(packageIdentifier);
+ if (pkg.containsErrors()) {
+ eventHandler.handle(
+ Event.error(
+ "package contains errors: "
+ + pkg.getNameFragment()
+ + ": "
+ + pkg.getFailureDetail().getMessage()));
+ }
return TargetPatternResolverUtil.resolvePackageTargets(pkg, actualPolicy);
} catch (NoSuchThingException e) {
String message =
@@ -162,6 +170,14 @@ public final class RecursivePackageProviderBackedTargetPatternResolver
ImmutableMap.Builder<PackageIdentifier, Collection<Target>> result = ImmutableMap.builder();
for (PackageIdentifier pkgId : pkgIds) {
Package pkg = pkgs.get(pkgId);
+ if (pkg.containsErrors()) {
+ eventHandler.handle(
+ Event.error(
+ "package contains errors: "
+ + pkg.getNameFragment()
+ + ": "
+ + pkg.getFailureDetail().getMessage()));
+ }
result.put(pkgId, TargetPatternResolverUtil.resolvePackageTargets(pkg, policy));
}
return result.buildOrThrow();
