aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java6
2 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
index b549caca51..bac43de158 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
@@ -342,7 +342,7 @@ public final class BuildTool {
if (e.isCatastrophic()) {
result.setCatastrophe();
}
- exitCode = ExitCode.BUILD_FAILURE;
+ exitCode = e.getExitCode() != null ? e.getExitCode() : ExitCode.BUILD_FAILURE;
} catch (InterruptedException e) {
exitCode = ExitCode.INTERRUPTED;
env.getReporter().handle(Event.error("build interrupted"));
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java b/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java
index 2a75f0d18f..33471d4aa3 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java
@@ -239,7 +239,11 @@ public class SkyframeBuilder implements Builder {
return false;
}
if (hasCycles || result.errorMap().isEmpty()) {
- // error map may be empty in the case of a catastrophe.
+ // error map may be empty in the case of a catastrophe, but the
+ // catastrophe-causing exception may be available.
+ if (result.getCatastrophe() != null) {
+ rethrow(result.getCatastrophe());
+ }
throw new BuildFailedException(null, hasCatastrophe);
} else {
rethrow(Preconditions.checkNotNull(result.getError().getException()));