]> source.dussan.org Git - jgit.git/commitdiff
pgm: Handle exceptions in DiffTree command 23/135423/1
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Jan 2019 20:12:03 +0000 (21:12 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Jan 2019 21:18:40 +0000 (22:18 +0100)
This avoids we show a stacktrace on the console by default when this
type of exception is thrown during the run method is executed.

Change-Id: I087b3e510682c68cae74c069b10050c7acb48a29
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java

index 42aabc2f4935ea2a993dc85786fb30ea3c310423..b6cf84165a68304b4f4df8bdfe1613251e298d74 100644 (file)
@@ -44,6 +44,7 @@
 
 package org.eclipse.jgit.pgm;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -74,7 +75,7 @@ class DiffTree extends TextBuiltin {
 
        /** {@inheritDoc} */
        @Override
-       protected void run() throws Exception {
+       protected void run() {
                try (TreeWalk walk = new TreeWalk(db)) {
                        walk.setRecursive(recursive);
                        for (AbstractTreeIterator i : trees)
@@ -116,6 +117,8 @@ class DiffTree extends TextBuiltin {
                                outw.print(walk.getPathString());
                                outw.println();
                        }
+               } catch (IOException e) {
+                       throw die(e.getMessage(), e);
                }
        }
 }