Remove remaining undetailed BuildFailedException constructor
Some loading-phase-related failure modes have placeholder detailed codes
to be improved when loading-phase failures are detailed.
RELNOTES: None.
PiperOrigin-RevId: 318366815
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java
index ae03826..3c63b34 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java
@@ -22,6 +22,7 @@
import com.google.devtools.build.lib.actions.ActionGraph;
import com.google.devtools.build.lib.actions.PackageRoots;
import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection;
+import com.google.devtools.build.lib.server.FailureDetails.FailureDetail;
import com.google.devtools.build.lib.skyframe.AspectValueKey.AspectKey;
import java.util.Collection;
import javax.annotation.Nullable;
@@ -34,7 +35,7 @@
private final ImmutableSet<ConfiguredTarget> targetsToBuild;
@Nullable private final ImmutableList<ConfiguredTarget> targetsToTest;
private final ImmutableSet<ConfiguredTarget> targetsToSkip;
- @Nullable private final String error;
+ @Nullable private final FailureDetail failureDetail;
private final ActionGraph actionGraph;
private final ArtifactsToOwnerLabels topLevelArtifactsToOwnerLabels;
private final ImmutableSet<ConfiguredTarget> parallelTests;
@@ -52,7 +53,7 @@
ImmutableMap<AspectKey, ConfiguredAspect> aspects,
@Nullable ImmutableList<ConfiguredTarget> targetsToTest,
ImmutableSet<ConfiguredTarget> targetsToSkip,
- @Nullable String error,
+ @Nullable FailureDetail failureDetail,
ActionGraph actionGraph,
ArtifactsToOwnerLabels topLevelArtifactsToOwnerLabels,
ImmutableSet<ConfiguredTarget> parallelTests,
@@ -67,7 +68,7 @@
this.aspects = aspects;
this.targetsToTest = targetsToTest;
this.targetsToSkip = targetsToSkip;
- this.error = error;
+ this.failureDetail = failureDetail;
this.actionGraph = actionGraph;
this.topLevelArtifactsToOwnerLabels = topLevelArtifactsToOwnerLabels;
this.parallelTests = parallelTests;
@@ -131,15 +132,14 @@
return parallelTests;
}
- /**
- * Returns an error description (if any).
- */
- @Nullable public String getError() {
- return error;
+ /** Returns a {@link FailureDetail}, if any failures occurred. */
+ @Nullable
+ public FailureDetail getFailureDetail() {
+ return failureDetail;
}
public boolean hasError() {
- return error != null;
+ return failureDetail != null;
}
/**
@@ -176,7 +176,7 @@
aspects,
targetsToTest,
targetsToSkip,
- error,
+ failureDetail,
actionGraph,
topLevelArtifactsToOwnerLabels,
Sets.union(parallelTests, exclusiveTests).immutableCopy(),
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BUILD b/src/main/java/com/google/devtools/build/lib/analysis/BUILD
index b9598c2..afc5ee7 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BUILD
@@ -620,6 +620,7 @@
"//src/main/java/com/google/devtools/build/lib/util",
"//src/main/java/com/google/devtools/build/skyframe",
"//src/main/java/com/google/devtools/build/skyframe:skyframe-objects",
+ "//src/main/protobuf:failure_details_java_proto",
"//third_party:flogger",
"//third_party:guava",
"//third_party:jsr305",
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
index c042a1c..a8b8df5 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
@@ -66,6 +66,11 @@
import com.google.devtools.build.lib.pkgcache.PackageManager.PackageManagerStatistics;
import com.google.devtools.build.lib.profiler.Profiler;
import com.google.devtools.build.lib.profiler.SilentCloseable;
+import com.google.devtools.build.lib.server.FailureDetails;
+import com.google.devtools.build.lib.server.FailureDetails.Analysis;
+import com.google.devtools.build.lib.server.FailureDetails.FailureDetail;
+import com.google.devtools.build.lib.server.FailureDetails.TargetPatterns;
+import com.google.devtools.build.lib.server.FailureDetails.TargetPatterns.Code;
import com.google.devtools.build.lib.skyframe.AspectValueKey;
import com.google.devtools.build.lib.skyframe.AspectValueKey.AspectKey;
import com.google.devtools.build.lib.skyframe.BuildConfigurationValue;
@@ -523,8 +528,8 @@
ImmutableSet<ConfiguredTarget> parallelTests = testsPair.first;
ImmutableSet<ConfiguredTarget> exclusiveTests = testsPair.second;
- String error =
- createErrorMessage(loadingResult, skyframeAnalysisResult, topLevelTargetsWithConfigs);
+ FailureDetail failureDetail =
+ createFailureDetail(loadingResult, skyframeAnalysisResult, topLevelTargetsWithConfigs);
final WalkableGraph graph = skyframeAnalysisResult.getWalkableGraph();
final ActionGraph actionGraph =
@@ -558,7 +563,7 @@
aspects,
allTargetsToTest == null ? null : ImmutableList.copyOf(allTargetsToTest),
ImmutableSet.copyOf(targetsToSkip),
- error,
+ failureDetail,
actionGraph,
artifactsToOwnerLabelsBuilder.build(),
parallelTests,
@@ -575,22 +580,38 @@
* interleaved, but sequential on the single target scale).
*/
@Nullable
- public static String createErrorMessage(
+ public static FailureDetail createFailureDetail(
TargetPatternPhaseValue loadingResult,
@Nullable SkyframeAnalysisResult skyframeAnalysisResult,
@Nullable TopLevelTargetsAndConfigsResult topLevelTargetsAndConfigs) {
if (loadingResult.hasError()) {
- return "command succeeded, but there were errors parsing the target pattern";
+ return FailureDetail.newBuilder()
+ .setMessage("command succeeded, but there were errors parsing the target pattern")
+ .setTargetPatterns(TargetPatterns.newBuilder().setCode(Code.TARGET_PATTERN_PARSE_FAILURE))
+ .build();
}
if (loadingResult.hasPostExpansionError()
|| (skyframeAnalysisResult != null && skyframeAnalysisResult.hasLoadingError())) {
- return "command succeeded, but there were loading phase errors";
+ return FailureDetail.newBuilder()
+ .setMessage("command succeeded, but there were loading phase errors")
+ .setAnalysis(Analysis.newBuilder().setCode(Analysis.Code.GENERIC_LOADING_PHASE_FAILURE))
+ .build();
}
if (topLevelTargetsAndConfigs != null && topLevelTargetsAndConfigs.hasError()) {
- return "command succeeded, but top level configurations could not be created";
+ return FailureDetail.newBuilder()
+ .setMessage("command succeeded, but top level configurations could not be created")
+ .setBuildConfiguration(
+ FailureDetails.BuildConfiguration.newBuilder()
+ .setCode(
+ FailureDetails.BuildConfiguration.Code
+ .TOP_LEVEL_CONFIGURATION_CREATION_FAILURE))
+ .build();
}
if (skyframeAnalysisResult != null && skyframeAnalysisResult.hasAnalysisError()) {
- return "command succeeded, but not all targets were analyzed";
+ return FailureDetail.newBuilder()
+ .setMessage("command succeeded, but not all targets were analyzed")
+ .setAnalysis(Analysis.newBuilder().setCode(Analysis.Code.NOT_ALL_TARGETS_ANALYZED))
+ .build();
}
return null;
}