summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-01-18 00:15:32 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-01-20 01:43:19 +0100
commitd789c9adabbd6004e687c5d9b54d84376a8f557a (patch)
treea74fff2ad1b62878cd21f76cc028638652ca12e8 /org.eclipse.jgit.pgm
parent518f420fe60bf0001352cdecd30309c02c90fc2f (diff)
downloadjgit-d789c9adabbd6004e687c5d9b54d84376a8f557a.tar.gz
jgit-d789c9adabbd6004e687c5d9b54d84376a8f557a.zip
pgm: Handle exceptions in Config 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. Also externalize error message. Change-Id: I909dc77385a672d8298053b12683c0cbbf9f2aa2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties1
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java15
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java1
3 files changed, 11 insertions, 6 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
index 69bf1723ef..418e59e480 100644
--- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
+++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
@@ -51,6 +51,7 @@ cleanRequireForce=clean.requireForce defaults to true and neither -n nor -f give
clonedEmptyRepository=warning: You appear to have cloned an empty repository.
cloningInto=Cloning into ''{0}''...
commitLabel=commit
+configOnlyListOptionSupported=only the --list option is currently supported
configFileNotFound=configuration file {0} not found
conflictingUsageOf_git_dir_andArguments=conflicting usage of --git-dir and arguments
couldNotCreateBranch=Could not create branch {0}: {1}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
index f762c0d052..979c6fa945 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
@@ -42,9 +42,9 @@ import java.io.IOException;
import java.util.Set;
import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.pgm.internal.CLIText;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.StringUtils;
@@ -70,12 +70,15 @@ class Config extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- if (list)
+ protected void run() {
+ if (!list) {
+ throw die(CLIText.get().configOnlyListOptionSupported);
+ }
+ try {
list();
- else
- throw new NotSupportedException(
- "only --list option is currently supported"); //$NON-NLS-1$
+ } catch (IOException | ConfigInvalidException e) {
+ throw die(e.getMessage(), e);
+ }
}
private void list() throws IOException, ConfigInvalidException {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
index 397b6b14ba..6a8a03eaf7 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
@@ -165,6 +165,7 @@ public class CLIText extends TranslationBundle {
/***/ public String clonedEmptyRepository;
/***/ public String cloningInto;
/***/ public String commitLabel;
+ /***/ public String configOnlyListOptionSupported;
/***/ public String conflictingUsageOf_git_dir_andArguments;
/***/ public String couldNotCreateBranch;
/***/ public String dateInfo;