# HG changeset patch # User Dmitry Neverov # Date 1408733551 -7200 # Node ID 206021e7175e1f6552b03af61f83cea4ae5c868f # Parent b1b878449326d3283fdfe561f41088aca98d87f0 Don't loose command-line error diff -r b1b878449326 -r 206021e7175e mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java --- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java Wed Aug 13 11:09:17 2014 +0200 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java Fri Aug 22 20:52:31 2014 +0200 @@ -111,6 +111,8 @@ assert e != null; throw new MercurialNotFoundException(getCommand(), e); } + if (e != null) + throw new VcsException(message, e); throw new VcsException(message); } diff -r b1b878449326 -r 206021e7175e mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java Wed Aug 13 11:09:17 2014 +0200 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java Fri Aug 22 20:52:31 2014 +0200 @@ -124,10 +124,16 @@ } } - @Test(expectedExceptions = VcsException.class) + @Test public void should_detect_failure_when_delegate_has_exception() throws VcsException { - CommandResult commandResult = commandResultFor(execResult().withException(new RuntimeException())); - commandResult.checkCommandFailed(); + RuntimeException error = new RuntimeException(); + CommandResult commandResult = commandResultFor(execResult().withException(error)); + try { + commandResult.checkCommandFailed(); + fail("exception is not detected"); + } catch (VcsException e) { + assertEquals(error, e.getCause()); + } } public void exception_should_not_contain_command_stdout_or_stderr() {