Print further details on an AbruptExitException. Otherwise we just get a trivial message with the summary of the exception that caused the failure... but zero context even if it exists. This is a requirement to get useful information when we fail hard. Dumping a stack trace may not be the nicest for the user, but given that this is improving a catch-all location, I'd rather get more information than nothing. If we need to print more succinct messages in other circumstances, we can special-case those. While here, also add missing trailing newlines to a few messages that need them. RELNOTES: None. PiperOrigin-RevId: 210409135
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java index a9df409..57dc16f 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
@@ -93,6 +93,7 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.io.PrintStream; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.time.Duration; @@ -951,13 +952,14 @@ dispatcher.shutdown(); return ExitCode.SUCCESS.getNumericExitCode(); } catch (OptionsParsingException e) { - outErr.printErr(e.getMessage()); + outErr.printErrLn(e.getMessage()); return ExitCode.COMMAND_LINE_ERROR.getNumericExitCode(); } catch (IOException e) { - outErr.printErr("I/O Error: " + e.getMessage()); + outErr.printErrLn("I/O Error: " + e.getMessage()); return ExitCode.BUILD_FAILURE.getNumericExitCode(); } catch (AbruptExitException e) { - outErr.printErr(e.getMessage()); + outErr.printErrLn(e.getMessage()); + e.printStackTrace(new PrintStream(outErr.getErrorStream(), true)); return e.getExitCode().getNumericExitCode(); } finally { if (sigintHandler != null) {