]> source.dussan.org Git - jgit.git/commitdiff
pgm: Handle exceptions in LsTree command 34/135434/2
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Jan 2019 20:37:04 +0000 (21:37 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Jan 2019 23:54:14 +0000 (00:54 +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: Ib3ae59eeb90143eca1a0b515c59457a0eb2cc383
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java

index 01fa7eeb81d2e9ca82e79c437ad278c885f3a41c..d2bf9ac187db0ef3a557aa06f2d8d1297b33b989 100644 (file)
@@ -45,6 +45,7 @@
 
 package org.eclipse.jgit.pgm;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -72,7 +73,7 @@ class LsTree extends TextBuiltin {
 
        /** {@inheritDoc} */
        @Override
-       protected void run() throws Exception {
+       protected void run() {
                try (TreeWalk walk = new TreeWalk(db)) {
                        walk.reset(); // drop the first empty tree, which we do not need here
                        if (paths.size() > 0)
@@ -95,6 +96,8 @@ class LsTree extends TextBuiltin {
                                outw.print(QuotedString.GIT_PATH.quote(walk.getPathString()));
                                outw.println();
                        }
+               } catch (IOException e) {
+                       throw die(e.getMessage(), e);
                }
        }
 }