aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-01-05 02:02:28 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-01-07 13:42:01 +0000
commit7b324effe5a054b48132bf7f2894525f03b2b5c6 (patch)
tree2db69d6d643a61c5b70b24e347f7661b0529027b /src/main/java/com/google/devtools
parente7194d9758a740272dd0cb8ea456c996c7503485 (diff)
Don't throw a TargetParsingException/QueryException in keepGoing mode when we encounter a bad target pattern.
-- MOS_MIGRATED_REVID=111374219
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java
index d304382b18..78aab4a486 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java
@@ -33,7 +33,6 @@ import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.TargetParsingException;
import com.google.devtools.build.lib.cmdline.TargetPattern;
import com.google.devtools.build.lib.collect.CompactHashSet;
-import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.graph.Digraph;
import com.google.devtools.build.lib.packages.BuildFileContainsErrorsException;
@@ -497,8 +496,15 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> {
Map<String, SkyKey> keys = new HashMap<>(patterns.size());
for (String pattern : patterns) {
- keys.put(pattern, TargetPatternValue.key(pattern,
- TargetPatternEvaluator.DEFAULT_FILTERING_POLICY, parserPrefix));
+ try {
+ keys.put(
+ pattern,
+ TargetPatternValue.key(
+ pattern, TargetPatternEvaluator.DEFAULT_FILTERING_POLICY, parserPrefix));
+ } catch (TargetParsingException e) {
+ reportBuildFileError(caller, e.getMessage());
+ result.put(pattern, ImmutableSet.<Target>of());
+ }
}
// Get all the patterns in one batch call
Map<SkyKey, SkyValue> existingPatterns = graph.getSuccessfulValues(keys.values());
@@ -506,6 +512,10 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> {
Map<String, Set<Target>> patternsWithTargetsToFilter = new HashMap<>();
for (String pattern : patterns) {
SkyKey patternKey = keys.get(pattern);
+ if (patternKey == null) {
+ // Exception was thrown when creating key above. Skip.
+ continue;
+ }
TargetParsingException targetParsingException = null;
if (existingPatterns.containsKey(patternKey)) {
// The graph already contains a value or exception for this target pattern, so we use it.
@@ -542,13 +552,8 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> {
}
if (targetParsingException != null) {
- if (!keepGoing) {
- throw targetParsingException;
- } else {
- eventHandler.handle(Event.error("Evaluation of query \"" + caller + "\" failed: "
- + targetParsingException.getMessage()));
- result.put(pattern, ImmutableSet.<Target>of());
- }
+ reportBuildFileError(caller, targetParsingException.getMessage());
+ result.put(pattern, ImmutableSet.<Target>of());
}
}
// filterTargetsNotInGraph does graph lookups. So we batch all the queries in one call.