1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +01:00

Add message String to ConnectionException

This commit is contained in:
Florian Schmaus 2014-09-24 13:34:25 +02:00
parent 7219f4b90c
commit b81c00d340
2 changed files with 14 additions and 2 deletions

View file

@ -169,10 +169,22 @@ public class SmackException extends Exception {
failedAddresses = new ArrayList<HostAddress>(0);
}
public ConnectionException(List<HostAddress> failedAddresses) {
private ConnectionException(String message, List<HostAddress> failedAddresses) {
super(message);
this.failedAddresses = failedAddresses;
}
public static ConnectionException from(List<HostAddress> failedAddresses) {
StringBuilder sb = new StringBuilder("The following addresses failed: ");
for (HostAddress hostAddress : failedAddresses) {
sb.append(hostAddress.getErrorMessage());
sb.append(", ");
}
// Remove the last whitespace
sb.deleteCharAt(sb.length());
return new ConnectionException(sb.toString(), failedAddresses);
}
public List<HostAddress> getFailedAddresses() {
return failedAddresses;
}

View file

@ -592,7 +592,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// There are no more host addresses to try
// throw an exception and report all tried
// HostAddresses in the exception
throw new ConnectionException(failedAddresses);
throw ConnectionException.from(failedAddresses);
}
}
socketClosed = false;