summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ant
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2016-10-18 13:17:26 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2016-10-18 14:15:53 +0900
commita3c0a7f9c4fb3c0fce7431f989f59a4ebe68de07 (patch)
tree498c1db210831fd861aa99cac14b3bb2ab9312f6 /org.eclipse.jgit.ant
parent4e3c5e1f13455f3c005307015d3cf9f9ac5e4705 (diff)
downloadjgit-a3c0a7f9c4fb3c0fce7431f989f59a4ebe68de07.tar.gz
jgit-a3c0a7f9c4fb3c0fce7431f989f59a4ebe68de07.zip
Git{Add|Clone}Task: Catch specific exceptions rather than Exception
Change-Id: If3db5a1375485e97f9811546e310e441475db1a6 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.ant')
-rw-r--r--org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java3
-rw-r--r--org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCloneTask.java12
2 files changed, 9 insertions, 6 deletions
diff --git a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java
index b9a868826e..fdd419bd64 100644
--- a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitAddTask.java
+++ b/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);
}
diff --git a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCloneTask.java b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCloneTask.java
index f23f3b753d..b2cb35cbef 100644
--- a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCloneTask.java
+++ b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCloneTask.java
@@ -49,12 +49,14 @@ 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;
/**
* Clone a repository into a new directory.
- *
+ *
* @see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html"
* >git-clone(1)</a>
*/
@@ -76,9 +78,9 @@ public class GitCloneTask extends Task {
/**
* The optional directory associated with the clone operation. If the
* directory isn't set, a name associated with the source uri will be used.
- *
+ *
* @see URIish#getHumanishName()
- *
+ *
* @param destination
* the directory to clone to
*/
@@ -105,12 +107,12 @@ public class GitCloneTask extends Task {
@Override
public void execute() throws BuildException {
log("Cloning repository " + uri);
-
+
CloneCommand clone = Git.cloneRepository();
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);
}