Skip to content

Commit

Permalink
[JENKINS-26748] avoid null in error log when no branch specified
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeloof committed Mar 5, 2015
1 parent 7308bc3 commit 0d477d7
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -1833,7 +1833,10 @@ public void execute() throws GitException, InterruptedException {
if (Pattern.compile("index\\.lock").matcher(e.getMessage()).find()) {
throw new GitLockFailedException("Could not lock repository. Please try again", e);
} else {
throw new GitException("Could not checkout " + branch + " with start point " + ref, e);
if (branch != null)
throw new GitException("Could not checkout " + branch + " with start point " + ref, e);
else
throw new GitException("Could not checkout " + ref, e);

This comment has been minimized.

Copy link
@MarkEWaite

MarkEWaite Mar 5, 2015

Contributor

Would it help the diagnosis if the GitException message included the message from the causing exception, as in throw new GitException("Could not checkout " + ref + ", " + e.getMessage(), e); ?

Or should some upper level method already be peeking "inside" the exception and displaying more information if there is a causing exception?

This comment has been minimized.

Copy link
@ndeloof

ndeloof Mar 5, 2015

Author Contributor

I'm not sure yet which policy to adopt. I'm investigating on some odd issue, hope to get a better diagnostic

This comment has been minimized.

This comment has been minimized.

Copy link
@ndeloof

ndeloof Mar 5, 2015

Author Contributor

This is not about finding a nice way to propagate the exception, but to understand circumstances such issue occurs and better handle it from a functional point of view - or even better: prevent it.

This comment has been minimized.

Copy link
@MarkEWaite

MarkEWaite Mar 6, 2015

Contributor

I agree that we want to understand the conditions which cause the failures and handle them or prevent them.

Wouldn't it help with the diagnosis if the exception e were provided to the user while we're trying to learn how to prevent exception e from happening?

I wonder if not displaying the cause exception is another unhealthy side effect of the changes I allowed through in June 2014 around use of AbortException. Refer to 1c1bb6 for that code change. I submitted a placeholder bug JENKINS-26255 to remind me that it seems like previously clear exception cases have become less clear.

}
} catch (InterruptedException e) {
final File indexFile = new File(workspace.getPath() + File.separator
Expand Down

0 comments on commit 0d477d7

Please sign in to comment.