commit 62a00aa9547353e45fd67fa018045ccc34bac4c2
parent 3a3f801afd2f7ce8b649948b2655fe91dd863c06
Author: Daniel Gultsch <daniel@gultsch.de>
Date: Fri, 10 Jun 2016 10:54:14 +0200
log registration failed reason
Diffstat:
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/main/java/eu/siacs/ComplianceTester.java b/src/main/java/eu/siacs/ComplianceTester.java
@@ -36,7 +36,7 @@ public class ComplianceTester {
System.exit(1);
return;
} catch (RegistrationHelper.RegistrationFailed e) {
- System.out.println("registration failed on server "+jid.getDomain());
+ System.out.println("registration failed on server "+jid.getDomain()+" "+e.getMessage());
System.exit(1);
return;
}
diff --git a/src/main/java/eu/siacs/RegistrationHelper.java b/src/main/java/eu/siacs/RegistrationHelper.java
@@ -9,11 +9,15 @@ import rocks.xmpp.extensions.register.model.Registration;
import java.math.BigInteger;
import java.security.SecureRandom;
-public class RegistrationHelper {
- public static String register(Jid jid) throws RegistrationFailed, RegistrationNotSupported {
+class RegistrationHelper {
+ static String register(Jid jid) throws RegistrationFailed, RegistrationNotSupported {
XmppClient client = XmppClient.create(jid.getDomain());
try {
client.connect(jid);
+ } catch(XmppException e) {
+ throw new RegistrationFailed("unable to connect to server");
+ }
+ try {
RegistrationManager registrationManager = client.getManager(RegistrationManager.class);
if (registrationManager.isRegistrationSupported().getResult()) {
String password = new BigInteger(64, new SecureRandom()).toString(36);
@@ -27,19 +31,18 @@ public class RegistrationHelper {
throw new RegistrationNotSupported();
}
} catch (XmppException e) {
- throw new RegistrationFailed();
+ throw new RegistrationFailed(e.getMessage());
}
}
- private abstract static class RegistrationException extends Exception {
-
- }
- public static class RegistrationNotSupported extends RegistrationException {
+ static class RegistrationNotSupported extends Exception {
}
- public static class RegistrationFailed extends RegistrationException {
-
+ static class RegistrationFailed extends Exception {
+ RegistrationFailed(String message) {
+ super(message);
+ }
}
}