Skip to content

Commit

Permalink
fix: show error log when command fails (#965)
Browse files Browse the repository at this point in the history
internal ref: b/309442390
  • Loading branch information
meltsufin committed Nov 19, 2023
1 parent f3a77a5 commit be7f7c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CommandExitException extends Exception {
* @param errorLog additional loggable error information
*/
public CommandExitException(int exitCode, @Nullable String errorLog) {
super("Process failed with exit code: " + exitCode);
super("Process failed with exit code: " + exitCode + (errorLog != null ? "\n" + errorLog : ""));
this.exitCode = exitCode;
this.errorLog = errorLog;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void testCall_nonZeroExit()
testCommandCaller.call(fakeCommand, fakeWorkingDirectory, fakeEnvironment);
Assert.fail("CommandExitException expected but not found.");
} catch (CommandExitException ex) {
Assert.assertEquals("Process failed with exit code: 10", ex.getMessage());
Assert.assertEquals("Process failed with exit code: 10\nstdout\nstderr", ex.getMessage());
Assert.assertEquals(10, ex.getExitCode());
Assert.assertEquals("stdout\nstderr", ex.getErrorLog());
}
Expand Down

0 comments on commit be7f7c8

Please sign in to comment.