mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Add message String to ConnectionException
This commit is contained in:
parent
7219f4b90c
commit
b81c00d340
2 changed files with 14 additions and 2 deletions
|
@ -169,10 +169,22 @@ public class SmackException extends Exception {
|
||||||
failedAddresses = new ArrayList<HostAddress>(0);
|
failedAddresses = new ArrayList<HostAddress>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectionException(List<HostAddress> failedAddresses) {
|
private ConnectionException(String message, List<HostAddress> failedAddresses) {
|
||||||
|
super(message);
|
||||||
this.failedAddresses = failedAddresses;
|
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() {
|
public List<HostAddress> getFailedAddresses() {
|
||||||
return failedAddresses;
|
return failedAddresses;
|
||||||
}
|
}
|
||||||
|
|
|
@ -592,7 +592,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
// There are no more host addresses to try
|
// There are no more host addresses to try
|
||||||
// throw an exception and report all tried
|
// throw an exception and report all tried
|
||||||
// HostAddresses in the exception
|
// HostAddresses in the exception
|
||||||
throw new ConnectionException(failedAddresses);
|
throw ConnectionException.from(failedAddresses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
socketClosed = false;
|
socketClosed = false;
|
||||||
|
|
Loading…
Reference in a new issue