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('-');
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);
try {
min = Integer.parseInt(sMin);
} 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);
if (sMax.equals(ALL_NODES_VALUE)) {
@ -52,7 +52,7 @@ final class AutoExpandReplicas {
try {
max = Integer.parseInt(sMax);
} 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);

View File

@ -46,14 +46,14 @@ public class AutoExpandReplicasTests extends ESTestCase {
AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "boom").build());
fail();
} 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 {
AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "1-boom").build());
fail();
} 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());
}
@ -61,7 +61,7 @@ public class AutoExpandReplicasTests extends ESTestCase {
AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "boom-1").build());
fail();
} 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());
}