fix more excpption useage

This commit is contained in:
Simon Willnauer 2015-12-16 12:00:34 +01:00
parent 9cf2f42d15
commit 32881c08b3
2 changed files with 3 additions and 0 deletions

View File

@ -120,6 +120,8 @@ public class Setting<T> extends ToXContentToBytes {
return parser.apply(value); return parser.apply(value);
} catch (ElasticsearchParseException ex) { } catch (ElasticsearchParseException ex) {
throw new IllegalArgumentException(ex.getMessage(), ex); throw new IllegalArgumentException(ex.getMessage(), ex);
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Failed to parse value [" + value + "] for setting [" + getKey() + "]", ex);
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
throw ex; throw ex;
} catch (Exception t) { } catch (Exception t) {

View File

@ -91,6 +91,7 @@ public class SettingsUpdaterTests extends ESTestCase {
Settings.builder().put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), "not a float").put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 1.0f).build()); Settings.builder().put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), "not a float").put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 1.0f).build());
fail("all or nothing"); fail("all or nothing");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
logger.info("", ex);
assertEquals("Failed to parse value [not a float] for setting [cluster.routing.allocation.balance.index]", ex.getMessage()); assertEquals("Failed to parse value [not a float] for setting [cluster.routing.allocation.balance.index]", ex.getMessage());
} }
assertNull("updater only does a dryRun", index.get()); assertNull("updater only does a dryRun", index.get());