diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/TomlConfigFileParser.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/TomlConfigFileParser.java index aee91f3dfb..5b4a48075f 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/TomlConfigFileParser.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/TomlConfigFileParser.java @@ -42,8 +42,8 @@ public class TomlConfigFileParser { if (result.hasErrors()) { final String errors = - result.errors().stream().map(TomlParseError::toString).collect(Collectors.joining("%n")); - throw new Exception("Invalid TOML configuration : " + errors); + result.errors().stream().map(TomlParseError::toString).collect(Collectors.joining("\n")); + throw new Exception("Invalid TOML configuration: \n" + errors); } return checkConfigurationValidity(result, toml); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/DefaultCommandValues.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/DefaultCommandValues.java index f9f9cb2881..cf9df00f65 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/DefaultCommandValues.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/DefaultCommandValues.java @@ -88,12 +88,12 @@ interface DefaultCommandValues { } // Try to create it, then verify if the provided path is not already existing and is not a - // directory .Otherwise, if it doesn't exist or exists but is already a directory, + // directory. Otherwise, if it doesn't exist or exists but is already a directory, // Runner will use it to store data. try { Files.createDirectories(pantheonHome); } catch (final FileAlreadyExistsException e) { - // Only thrown if it exist but is not a directory + // Only thrown if it exists but is not a directory throw new CommandLine.ParameterException( new CommandLine(command), String.format( diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index 5847fe20c6..760d55473d 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -318,7 +318,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { private Long configureRefreshDelay(final Long refreshDelay) { if (refreshDelay < DEFAULT_MIN_REFRESH_DELAY || refreshDelay > DEFAULT_MAX_REFRESH_DELAY) { throw new ParameterException( - new CommandLine(this), + this.commandLine, String.format( "Refresh delay must be a positive integer between %s and %s", String.valueOf(DEFAULT_MIN_REFRESH_DELAY), @@ -547,7 +547,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { //noinspection ConstantConditions if (isMiningEnabled && coinbase == null) { throw new ParameterException( - new CommandLine(this), + this.commandLine, "Unable to mine without a valid coinbase. Either disable mining (remove --miner-enabled)" + "or specify the beneficiary of mining (via --miner-coinbase
)"); } @@ -574,7 +574,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { metricsConfiguration(), permissioningConfiguration); } catch (Exception e) { - throw new ParameterException(new CommandLine(this), e.getMessage()); + throw new ParameterException(this.commandLine, e.getMessage()); } } @@ -590,7 +590,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { PermissioningConfigurationValidator.areAllBootnodesAreInWhitelist( ethNetworkConfig, permissioningConfiguration); } catch (final Exception e) { - throw new ParameterException(new CommandLine(this), e.getMessage()); + throw new ParameterException(this.commandLine, e.getMessage()); } } @@ -609,9 +609,9 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { .privacyParameters(privacyParameters()) .build(); } catch (final InvalidConfigurationException e) { - throw new ExecutionException(new CommandLine(this), e.getMessage()); + throw new ExecutionException(this.commandLine, e.getMessage()); } catch (final IOException e) { - throw new ExecutionException(new CommandLine(this), "Invalid path", e); + throw new ExecutionException(this.commandLine, "Invalid path", e); } } @@ -694,7 +694,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { MetricsConfiguration metricsConfiguration() { if (isMetricsEnabled && isMetricsPushEnabled) { throw new ParameterException( - new CommandLine(this), + this.commandLine, "--metrics-enabled option and --metrics-push-enabled option can't be used at the same " + "time. Please refer to CLI reference for more details about this constraint."); } @@ -858,7 +858,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { // if user provided it and provided the genesis file option at the same time, it raises a // conflict error throw new ParameterException( - new CommandLine(this), + this.commandLine, "--network option and --genesis-file option can't be used at the same time. Please " + "refer to CLI reference for more details about this constraint."); } @@ -882,9 +882,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { .orElse(EthNetworkConfig.getNetworkConfig(MAINNET).getNetworkId())); } catch (final DecodeException e) { throw new ParameterException( - new CommandLine(this), - String.format("Unable to parse genesis file %s.", genesisFile), - e); + this.commandLine, String.format("Unable to parse genesis file %s.", genesisFile), e); } } @@ -913,9 +911,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { return Resources.toString(genesisFile().toURI().toURL(), UTF_8); } catch (final IOException e) { throw new ParameterException( - new CommandLine(this), - String.format("Unable to load genesis file %s.", genesisFile()), - e); + this.commandLine, String.format("Unable to load genesis file %s.", genesisFile()), e); } }