]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/App.java
Warn when using a legacy data path
[signal-cli] / src / main / java / org / asamk / signal / App.java
index 5b2c91c6a2faca1d56478f8bca6313b73c3ea746..af3fea4c5e92c0dfbd5a83687f684473ea0bd59f 100644 (file)
@@ -133,16 +133,15 @@ public class App {
 
         if (username == null) {
             var usernames = Manager.getAllLocalUsernames(dataPath);
-            if (usernames.size() == 0) {
-                throw new UserErrorException("No local users found, you first need to register or link an account");
-            }
 
             if (command instanceof MultiLocalCommand) {
                 handleMultiLocalCommand((MultiLocalCommand) command, dataPath, serviceEnvironment, usernames);
                 return;
             }
 
-            if (usernames.size() > 1) {
+            if (usernames.size() == 0) {
+                throw new UserErrorException("No local users found, you first need to register or link an account");
+            } else if (usernames.size() > 1) {
                 throw new UserErrorException(
                         "Multiple users found, you need to specify a username (phone number) with -u");
             }
@@ -181,7 +180,11 @@ public class App {
         try {
             manager = RegistrationManager.init(username, dataPath, serviceEnvironment, BaseConfig.USER_AGENT);
         } catch (Throwable e) {
-            throw new UnexpectedErrorException("Error loading or creating state file: " + e.getMessage());
+            throw new UnexpectedErrorException("Error loading or creating state file: "
+                    + e.getMessage()
+                    + " ("
+                    + e.getClass().getSimpleName()
+                    + ")");
         }
         try (var m = manager) {
             command.handleCommand(ns, m);
@@ -211,7 +214,11 @@ public class App {
     ) throws CommandException {
         final var managers = new ArrayList<Manager>();
         for (String u : usernames) {
-            managers.add(loadManager(u, dataPath, serviceEnvironment));
+            try {
+                managers.add(loadManager(u, dataPath, serviceEnvironment));
+            } catch (CommandException e) {
+                logger.warn("Ignoring {}: {}", u, e.getMessage());
+            }
         }
 
         command.handleCommand(ns, managers);
@@ -234,7 +241,13 @@ public class App {
         } catch (NotRegisteredException e) {
             throw new UserErrorException("User " + username + " is not registered.");
         } catch (Throwable e) {
-            throw new UnexpectedErrorException("Error loading state file for user " + username + ": " + e.getMessage());
+            throw new UnexpectedErrorException("Error loading state file for user "
+                    + username
+                    + ": "
+                    + e.getMessage()
+                    + " ("
+                    + e.getClass().getSimpleName()
+                    + ")");
         }
 
         try {
@@ -296,11 +309,13 @@ public class App {
 
         var legacySettingsPath = new File(configPath, "signal");
         if (legacySettingsPath.exists()) {
+            logger.warn("Using legacy data path \"{}\", please move it to \"{}\".", legacySettingsPath, dataPath);
             return legacySettingsPath;
         }
 
         legacySettingsPath = new File(configPath, "textsecure");
         if (legacySettingsPath.exists()) {
+            logger.warn("Using legacy data path \"{}\", please move it to \"{}\".", legacySettingsPath, dataPath);
             return legacySettingsPath;
         }