From a19ad89d990777990c9e422ca478ff0b314cd5fa Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 20 Jan 2019 21:37:04 +0100 Subject: [PATCH] pgm: Handle exceptions in LsTree command 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 --- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java index 01fa7eeb8..d2bf9ac18 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java @@ -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); } } }