Browse Source

Git{Add|Clone}Task: Catch specific exceptions rather than Exception

Change-Id: If3db5a1375485e97f9811546e310e441475db1a6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.6
David Pursehouse 8 years ago
parent
commit
a3c0a7f9c4
  1. 3
      org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java
  2. 4
      org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCloneTask.java

3
org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java

@ -53,6 +53,7 @@ import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.resources.Union;
import org.eclipse.jgit.api.AddCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryCache;
@ -135,7 +136,7 @@ public class GitAddTask extends Task {
gitAdd.addFilepattern(toAdd);
}
gitAdd.call();
} catch (Exception e) {
} catch (IOException | GitAPIException e) {
throw new BuildException("Could not add files to index." + src, e);
}

4
org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCloneTask.java

@ -49,6 +49,8 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.transport.URIish;
@ -110,7 +112,7 @@ public class GitCloneTask extends Task {
try {
clone.setURI(uri).setDirectory(destination).setBranch(branch).setBare(bare);
clone.call().getRepository().close();
} catch (Exception e) {
} catch (GitAPIException | JGitInternalException e) {
log("Could not clone repository: " + e, e, Project.MSG_ERR);
throw new BuildException("Could not clone repository: " + e.getMessage(), e);
}

Loading…
Cancel
Save