aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2012-12-10 05:20:06 (EST)
committerGerrit Code Review @ Eclipse.org2013-01-08 06:26:36 (EST)
commit928286ad8f5713dbacee033250ee63fc7072e6bc (patch)
treec15c3b1208f85cebd5518eaae78148a9fc22c3ae
parent3328f45dde327cf344bed2aa34838b777e0dd5b8 (diff)
downloadjgit-928286ad8f5713dbacee033250ee63fc7072e6bc.zip
jgit-928286ad8f5713dbacee033250ee63fc7072e6bc.tar.gz
jgit-928286ad8f5713dbacee033250ee63fc7072e6bc.tar.bz2
Return info about config subsection when trying to get an invalid enumrefs/changes/33/9133/2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java10
2 files changed, 25 insertions, 4 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
index f02012e..9836036 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
@@ -293,6 +293,25 @@ public class ConfigTest {
}
@Test
+ public void testGetInvalidEnum() throws ConfigInvalidException {
+ Config c = parse("[a]\n\tb = invalid\n");
+ try {
+ c.getEnum("a", null, "b", TestEnum.ONE_TWO);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Invalid value: a.b=invalid", e.getMessage());
+ }
+
+ c = parse("[a \"b\"]\n\tc = invalid\n");
+ try {
+ c.getEnum("a", "b", "c", TestEnum.ONE_TWO);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Invalid value: a.b.c=invalid", e.getMessage());
+ }
+ }
+
+ @Test
public void testSetEnum() {
final Config c = new Config();
c.setEnum("s", "b", "c", TestEnum.ONE_TWO);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
index 348e117..fb78d0e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -412,11 +412,13 @@ public class Config {
}
if (subsection != null)
- throw new IllegalArgumentException(MessageFormat.format(JGitText
- .get().enumValueNotSupported3, section, name, value));
+ throw new IllegalArgumentException(MessageFormat.format(
+ JGitText.get().enumValueNotSupported3, section, subsection,
+ name, value));
else
- throw new IllegalArgumentException(MessageFormat.format(JGitText
- .get().enumValueNotSupported2, section, name, value));
+ throw new IllegalArgumentException(
+ MessageFormat.format(JGitText.get().enumValueNotSupported2,
+ section, name, value));
}
/**