diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-04-13 20:09:31 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-04-13 20:09:31 +0200 |
commit | 021feb4347cbf5a9954c60bd9d4ff9e286aa81e4 (patch) | |
tree | f1001abb6fd38be27b9c364e6d64e516935e2ed0 /vespaclient-java/src | |
parent | e40c993de0b870a2aec7fff91a64ac229b36fd0b (diff) |
Improve error messages
Diffstat (limited to 'vespaclient-java/src')
-rw-r--r-- | vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java | 18 | ||||
-rw-r--r-- | vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java index 307cf979c33..83199c76e5a 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java @@ -25,6 +25,7 @@ import org.apache.commons.cli.Options; import java.io.*; import java.nio.charset.Charset; import java.util.Map; +import java.util.stream.Collectors; /** * Client using visiting, used by the vespa-visit command line tool. @@ -572,18 +573,14 @@ public class VdsVisit { protected static String resolveClusterRoute(ClusterList clusters, String wantedCluster) { if (clusters.getStorageClusters().size() == 0) { throw new IllegalArgumentException("Your Vespa cluster does not have any content clusters " + - "declared. Visiting feature is not available."); + "declared. Visiting feature is not available."); } ClusterDef found = null; - String names = ""; - for (ClusterDef c : clusters.getStorageClusters()) { - if (!names.isEmpty()) { - names += ", "; - } - names += c.getName(); - } + String names = clusters.getStorageClusters() + .stream().map(c -> "'" + c.getName() + "'") + .collect(Collectors.joining(", ")); if (wantedCluster != null) { for (ClusterDef c : clusters.getStorageClusters()) { if (c.getName().equals(wantedCluster)) { @@ -592,13 +589,14 @@ public class VdsVisit { } if (found == null) { throw new IllegalArgumentException("Your vespa cluster contains the content clusters " + - names + ", not " + wantedCluster + ". Please select a valid vespa cluster."); + names + ", not '" + wantedCluster + + "'. Please select a valid vespa cluster."); } } else if (clusters.getStorageClusters().size() == 1) { found = clusters.getStorageClusters().get(0); } else { throw new IllegalArgumentException("Your vespa cluster contains the content clusters " + - names + ". Please use the -c option to select one of them as a target for visiting."); + names + ". Please use the -c option to select one of them as a target for visiting."); } return "[Storage:cluster=" + found.getName() + ";clusterconfigid=" + found.getConfigId() + "]"; diff --git a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java index 20f3cbcfe23..d9efe2c5129 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespavisit/VdsVisitTestCase.java @@ -242,7 +242,9 @@ public class VdsVisitTestCase { try { VdsVisit.resolveClusterRoute(clusterList, "borkbork"); } catch (IllegalArgumentException e) { - assertTrue(e.getMessage().contains("Your vespa cluster contains the content clusters storage, not borkbork.")); + assertEquals("Your vespa cluster contains the content clusters 'storage', not 'borkbork'. " + + "Please select a valid vespa cluster.", + e.getMessage()); } } |