Add more information to NotConnectedException

This commit is contained in:
Florian Schmaus 2015-06-09 13:43:05 +02:00
parent a854e04d28
commit a85ba5311e
2 changed files with 12 additions and 2 deletions

View File

@ -166,6 +166,11 @@ public class SmackException extends Exception {
public NotConnectedException() {
super("Client is not, or no longer, connected");
}
public NotConnectedException(XMPPConnection connection, String details) {
super("The connection " + connection.toString() + " is no longer connected. "
+ details);
}
}
public static class IllegalStateChangeException extends SmackException {

View File

@ -1210,9 +1210,14 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
}
protected void throwNotConnectedExceptionIfDoneAndResumptionNotPossible() throws NotConnectedException {
if (done() && !isSmResumptionPossible()) {
final boolean done = done();
if (done) {
final boolean smResumptionPossbile = isSmResumptionPossible();
// Don't throw a NotConnectedException is there is an resumable stream available
throw new NotConnectedException();
if (!smResumptionPossbile) {
throw new NotConnectedException(XMPPTCPConnection.this, "done=" + done
+ " smResumptionPossible=" + smResumptionPossbile);
}
}
}