aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2017-03-16 18:26:10 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-03-17 12:26:08 +0000
commitf09bd07c89efd64c05f11cb79d8b70eb22b8fd67 (patch)
tree63d6de0a1d8bc6c48b039a311f0f9576f761cd3d /src/main/java
parentf405ebfb116423670388fd1d02aade823aadd62a (diff)
Display an error message when there is a status command error
This was printing, fairly unhelpfully `ERROR: Process exited with status 127.` when the .sh file did not exist. -- PiperOrigin-RevId: 150344684 MOS_MIGRATED_REVID=150344684
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java
index 58eab6db22..6b62f2bd06 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.bazel;
import static com.google.common.base.StandardSystemProperty.USER_NAME;
+import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
@@ -43,6 +44,7 @@ import com.google.devtools.build.lib.runtime.Command;
import com.google.devtools.build.lib.runtime.CommandEnvironment;
import com.google.devtools.build.lib.runtime.GotOptionsEvent;
import com.google.devtools.build.lib.runtime.WorkspaceBuilder;
+import com.google.devtools.build.lib.shell.BadExitStatusException;
import com.google.devtools.build.lib.shell.CommandException;
import com.google.devtools.build.lib.shell.CommandResult;
import com.google.devtools.build.lib.util.CommandBuilder;
@@ -120,11 +122,23 @@ public class BazelWorkspaceStatusModule extends BlazeModule {
+ options.workspaceStatusCommand));
CommandResult result = this.getWorkspaceStatusCommand.execute();
if (result.getTerminationStatus().success()) {
- return new String(result.getStdout());
+ return new String(result.getStdout(), UTF_8);
}
- throw new ActionExecutionException(
- "workspace status command failed: " + result.getTerminationStatus(), this, true);
+ throw new BadExitStatusException(
+ this.getWorkspaceStatusCommand,
+ result,
+ "workspace status command failed: " + result.getTerminationStatus());
}
+ } catch (BadExitStatusException e) {
+ String errorMessage = e.getMessage();
+ try {
+ actionExecutionContext.getFileOutErr().getOutputStream().write(
+ e.getResult().getStdout());
+ actionExecutionContext.getFileOutErr().getErrorStream().write(e.getResult().getStderr());
+ } catch (IOException e2) {
+ errorMessage = errorMessage + " and could not get stdout/stderr: " + e2.getMessage();
+ }
+ throw new ActionExecutionException(errorMessage, e, this, true);
} catch (CommandException e) {
throw new ActionExecutionException(e, this, true);
}