]> nmode's Git Repositories - signal-cli/commitdiff
Better logging for registration failure
authorAsamK <asamk@gmx.de>
Sun, 21 May 2023 09:15:49 +0000 (11:15 +0200)
committerAsamK <asamk@gmx.de>
Sun, 21 May 2023 09:15:49 +0000 (11:15 +0200)
lib/src/main/java/org/asamk/signal/manager/RegistrationManagerImpl.java
src/main/java/org/asamk/signal/commands/RegisterCommand.java

index 2951f1a7d085aa97c7f4c2077d1494f365a62fb1..0e3c9af003178730fbe2d8f96340117f374fe431 100644 (file)
@@ -39,6 +39,7 @@ import org.whispersystems.signalservice.api.push.ACI;
 import org.whispersystems.signalservice.api.push.PNI;
 import org.whispersystems.signalservice.api.push.SignalServiceAddress;
 import org.whispersystems.signalservice.api.push.exceptions.AlreadyVerifiedException;
+import org.whispersystems.signalservice.api.push.exceptions.DeprecatedVersionException;
 import org.whispersystems.signalservice.internal.push.VerifyAccountResponse;
 import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
 
@@ -114,16 +115,21 @@ class RegistrationManagerImpl implements RegistrationManager {
             throw new IOException("Account is registered in another environment: " + account.getServiceEnvironment());
         }
 
-        if (account.getAci() != null && attemptReactivateAccount()) {
-            return;
-        }
+        try {
+            if (account.getAci() != null && attemptReactivateAccount()) {
+                return;
+            }
 
-        String sessionId = NumberVerificationUtils.handleVerificationSession(accountManager,
-                account.getSessionId(account.getNumber()),
-                id -> account.setSessionId(account.getNumber(), id),
-                voiceVerification,
-                captcha);
-        NumberVerificationUtils.requestVerificationCode(accountManager, sessionId, voiceVerification);
+            String sessionId = NumberVerificationUtils.handleVerificationSession(accountManager,
+                    account.getSessionId(account.getNumber()),
+                    id -> account.setSessionId(account.getNumber(), id),
+                    voiceVerification,
+                    captcha);
+            NumberVerificationUtils.requestVerificationCode(accountManager, sessionId, voiceVerification);
+        } catch (DeprecatedVersionException e) {
+            logger.debug("Signal-Server returned deprecated version exception", e);
+            throw e;
+        }
     }
 
     @Override
index 5ba66d7a6c98991a0410bbfbc9624edfcc529a0f..3ff6dc094fade5b1f3d623ab739c311c526b3dc3 100644 (file)
@@ -92,7 +92,8 @@ public class RegisterCommand implements RegistrationCommand, JsonRpcRegistration
         } catch (NonNormalizedPhoneNumberException e) {
             throw new UserErrorException("Failed to register: " + e.getMessage(), e);
         } catch (IOException e) {
-            throw new IOErrorException("Failed to register: " + e.getMessage(), e);
+            throw new IOErrorException("Failed to register: %s (%s)".formatted(e.getMessage(),
+                    e.getClass().getSimpleName()), e);
         }
     }