Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
TOML error string fix. (#401)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Terry <mark.terry@consensys.net>
  • Loading branch information
mark-terry authored Dec 20, 2020
1 parent 87d5e88 commit a3650c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/main/java/net/consensys/orion/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ public static Config load(final InputStream is) throws IOException {
}

@VisibleForTesting
public static Config load(final InputStream is, Map<String, String> env) throws IOException {
public static Config load(final InputStream is, final Map<String, String> env) throws IOException {
return load(Configuration.fromToml(is, SCHEMA), env);
}

private static Config load(final Configuration configuration, Map<String, String> env) {
private static Config load(final Configuration configuration, final Map<String, String> env) {
final List<ConfigurationError> errors = configuration.errors();
if (!errors.isEmpty()) {
String errorString = errors.stream().limit(5).map(ConfigurationError::toString).collect(Collectors.joining("\n"));
String errorString =
errors.stream().limit(5).map(ConfigurationError::getMessage).collect(Collectors.joining("\n"));
if (errors.size() > 5) {
errorString += "\n...";
}
Expand Down
8 changes: 1 addition & 7 deletions src/test/java/net/consensys/orion/config/TomlConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,10 @@ void invalidConfigsThrowException() {
final ConfigException e = assertThrows(
ConfigException.class,
() -> Config.load(this.getClass().getClassLoader().getResourceAsStream("invalidConfigTest.toml")));
final String tuweniPrefix = "org.apache.tuweni.config.ConfigurationError: ";
final String message = tuweniPrefix
+ "Value of property 'clienturl' is not a valid URL (line 4, column 1)\n"
+ tuweniPrefix
final String message = "Value of property 'clienturl' is not a valid URL (line 4, column 1)\n"
+ "Value of property 'storage' must have storage type of \"leveldb\", \"mapdb\", \"sql\" or \"memory\" (line 11, column 1)\n"
+ tuweniPrefix
+ "Value of property 'othernodes' is not a valid URL (line 6, column 1)\n"
+ tuweniPrefix
+ "Value of property 'othernodes' is not a valid URL (line 6, column 1)\n"
+ tuweniPrefix
+ "Value of property 'tlsservertrust' should be \"whitelist\", \"ca\", \"ca-or-whitelist\", \"tofu\", \"insecure-tofa\", \"ca-or-tofu\", \"insecure-ca-or-tofa\", \"insecure-no-validation\", \"insecure-record\", or \"insecure-ca-or-record\" (line 9, column 1)\n"
+ "...";
assertEquals(message, e.getMessage());
Expand Down

0 comments on commit a3650c0

Please sign in to comment.