Format CLI error message when es.path.conf not set

This commit adds some formatting to the message displayed when
es.path.conf is not set.
This commit is contained in:
Jason Tedor 2017-07-30 09:49:55 +09:00
parent 8229a57c53
commit 4c37335f1d
2 changed files with 2 additions and 2 deletions

View File

@ -73,7 +73,7 @@ public abstract class EnvironmentAwareCommand extends Command {
protected Environment createEnv(final Terminal terminal, final Map<String, String> settings) throws UserException { protected Environment createEnv(final Terminal terminal, final Map<String, String> settings) throws UserException {
final String esPathConf = System.getProperty("es.path.conf"); final String esPathConf = System.getProperty("es.path.conf");
if (esPathConf == null) { if (esPathConf == null) {
throw new UserException(ExitCodes.CONFIG, "the system property es.path.conf must be set"); throw new UserException(ExitCodes.CONFIG, "the system property [es.path.conf] must be set");
} }
return InternalSettingsPreparer.prepareEnvironment(Settings.EMPTY, terminal, settings, getConfigPath(esPathConf)); return InternalSettingsPreparer.prepareEnvironment(Settings.EMPTY, terminal, settings, getConfigPath(esPathConf));
} }

View File

@ -54,7 +54,7 @@ public class EvilEnvironmentAwareCommandTests extends ESTestCase {
final TestEnvironmentAwareCommand command = new TestEnvironmentAwareCommand("test"); final TestEnvironmentAwareCommand command = new TestEnvironmentAwareCommand("test");
final UserException e = final UserException e =
expectThrows(UserException.class, () -> command.mainWithoutErrorHandling(new String[0], new MockTerminal())); expectThrows(UserException.class, () -> command.mainWithoutErrorHandling(new String[0], new MockTerminal()));
assertThat(e, hasToString(containsString("the system property es.path.conf must be set"))); assertThat(e, hasToString(containsString("the system property [es.path.conf] must be set")));
} }
@SuppressForbidden(reason = "clears system property es.path.conf as part of test setup") @SuppressForbidden(reason = "clears system property es.path.conf as part of test setup")