fix error message

This commit is contained in:
Simon Willnauer 2016-01-15 22:27:41 +01:00
parent 2eecb9c02d
commit cb0ea70b9d
2 changed files with 6 additions and 6 deletions

View File

@ -37,13 +37,13 @@ final class AutoExpandReplicas {
} }
final int dash = value.indexOf('-'); final int dash = value.indexOf('-');
if (-1 == dash) { if (-1 == dash) {
throw new IllegalArgumentException("failed to parse [" + IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS + "] form [" + value + "] at index " + dash); throw new IllegalArgumentException("failed to parse [" + IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS + "] from value: [" + value + "] at index " + dash);
} }
final String sMin = value.substring(0, dash); final String sMin = value.substring(0, dash);
try { try {
min = Integer.parseInt(sMin); min = Integer.parseInt(sMin);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new IllegalArgumentException("failed to parse [" + IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS + "] form [" + value + "] at index " + dash, e); throw new IllegalArgumentException("failed to parse [" + IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS + "] from value: [" + value + "] at index " + dash, e);
} }
String sMax = value.substring(dash + 1); String sMax = value.substring(dash + 1);
if (sMax.equals(ALL_NODES_VALUE)) { if (sMax.equals(ALL_NODES_VALUE)) {
@ -52,7 +52,7 @@ final class AutoExpandReplicas {
try { try {
max = Integer.parseInt(sMax); max = Integer.parseInt(sMax);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new IllegalArgumentException("failed to parse [" + IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS + "] form [" + value + "] at index " + dash, e); throw new IllegalArgumentException("failed to parse [" + IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS + "] from value: [" + value + "] at index " + dash, e);
} }
} }
return new AutoExpandReplicas(min, max, true); return new AutoExpandReplicas(min, max, true);

View File

@ -46,14 +46,14 @@ public class AutoExpandReplicasTests extends ESTestCase {
AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "boom").build()); AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "boom").build());
fail(); fail();
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
assertEquals("failed to parse [index.auto_expand_replicas] form [boom] at index -1", ex.getMessage()); assertEquals("failed to parse [index.auto_expand_replicas] from value: [boom] at index -1", ex.getMessage());
} }
try { try {
AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "1-boom").build()); AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "1-boom").build());
fail(); fail();
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
assertEquals("failed to parse [index.auto_expand_replicas] form [1-boom] at index 1", ex.getMessage()); assertEquals("failed to parse [index.auto_expand_replicas] from value: [1-boom] at index 1", ex.getMessage());
assertEquals("For input string: \"boom\"", ex.getCause().getMessage()); assertEquals("For input string: \"boom\"", ex.getCause().getMessage());
} }
@ -61,7 +61,7 @@ public class AutoExpandReplicasTests extends ESTestCase {
AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "boom-1").build()); AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "boom-1").build());
fail(); fail();
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
assertEquals("failed to parse [index.auto_expand_replicas] form [boom-1] at index 4", ex.getMessage()); assertEquals("failed to parse [index.auto_expand_replicas] from value: [boom-1] at index 4", ex.getMessage());
assertEquals("For input string: \"boom\"", ex.getCause().getMessage()); assertEquals("For input string: \"boom\"", ex.getCause().getMessage());
} }