1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-09 04:21:08 +01:00

Remove trailing comma in ConnectionException message

Also add SmackExceptionTest
This commit is contained in:
Florian Schmaus 2014-10-05 12:17:25 +02:00
parent f7517ab6cc
commit b6285679cd
2 changed files with 52 additions and 3 deletions

View file

@ -175,13 +175,14 @@ public class SmackException extends Exception {
}
public static ConnectionException from(List<HostAddress> failedAddresses) {
final String DELIMITER = ", ";
StringBuilder sb = new StringBuilder("The following addresses failed: ");
for (HostAddress hostAddress : failedAddresses) {
sb.append(hostAddress.getErrorMessage());
sb.append(", ");
sb.append(DELIMITER);
}
// Remove the last whitespace
sb.deleteCharAt(sb.length() - 1);
// Remove the last delimiter
sb.setLength(sb.length() - DELIMITER.length());
return new ConnectionException(sb.toString(), failedAddresses);
}