]> source.dussan.org Git - jgit.git/commitdiff
pgm: Handle exceptions in LsFiles command 31/135431/2
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Jan 2019 20:32:21 +0000 (21:32 +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: I7d71e194f0a7e4180094a9b36dbb55dd90c9722e

org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java

index dc13000d63aafd2245f19aab75cf996b0a2107a1..ef25844973392e5a4c56a7e005f4f9ea6083ee79 100644 (file)
@@ -48,11 +48,13 @@ import static org.eclipse.jgit.lib.FileMode.GITLINK;
 import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE;
 import static org.eclipse.jgit.lib.FileMode.SYMLINK;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 import org.eclipse.jgit.dircache.DirCacheIterator;
+import org.eclipse.jgit.errors.RevisionSyntaxException;
 import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.FileMode;
 import org.eclipse.jgit.lib.ObjectId;
@@ -72,7 +74,7 @@ class LsFiles extends TextBuiltin {
        private List<String> paths = new ArrayList<>();
 
        @Override
-       protected void run() throws Exception {
+       protected void run() {
                try (RevWalk rw = new RevWalk(db);
                                TreeWalk tw = new TreeWalk(db)) {
                        final ObjectId head = db.resolve(Constants.HEAD);
@@ -96,6 +98,8 @@ class LsFiles extends TextBuiltin {
                                                        QuotedString.GIT_PATH.quote(tw.getPathString()));
                                }
                        }
+               } catch (RevisionSyntaxException | IOException e) {
+                       throw die(e.getMessage(), e);
                }
        }