]> nmode's Git Repositories - signal-cli/commitdiff
Improve error messages when daemon is already running
authorAsamK <asamk@gmx.de>
Sun, 13 Feb 2022 19:08:02 +0000 (20:08 +0100)
committerAsamK <asamk@gmx.de>
Sun, 13 Feb 2022 19:08:30 +0000 (20:08 +0100)
src/main/java/org/asamk/signal/commands/Commands.java
src/main/java/org/asamk/signal/commands/DaemonCommand.java
src/main/java/org/asamk/signal/util/IOUtils.java

index aee9a7ba6d33f4534b017da58c1ff9b114683311..29b28da09ad5e9cc3cc766a25615d2b4a1ab2952 100644 (file)
@@ -29,8 +29,8 @@ public class Commands {
         addCommand(new RegisterCommand());
         addCommand(new RemoveContactCommand());
         addCommand(new RemoveDeviceCommand());
-        addCommand(new RemoteDeleteCommand());
         addCommand(new RemovePinCommand());
+        addCommand(new RemoteDeleteCommand());
         addCommand(new SendCommand());
         addCommand(new SendContactsCommand());
         addCommand(new SendReactionCommand());
index 79e0cd82965ab20f240afe14adf5385b5aae11a7..e224bf1c0a55ec4500fc1ecf581df5ade2aeca5e 100644 (file)
@@ -340,41 +340,39 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
         } else {
             busType = DBusConnection.DBusBusType.SESSION;
         }
+        DBusConnection conn;
         try {
-            var conn = DBusConnection.getConnection(busType);
+            conn = DBusConnection.getConnection(busType);
             dbusRunner.run(conn, DbusConfig.getObjectPath());
+        } catch (DBusException e) {
+            throw new UnexpectedErrorException("Dbus command failed: " + e.getMessage(), e);
+        }
 
+        try {
             conn.requestBusName(DbusConfig.getBusname());
-
-            logger.info("DBus daemon running on {} bus: {}", busType, DbusConfig.getBusname());
         } catch (DBusException e) {
-            logger.error("Dbus command failed", e);
-            throw new UnexpectedErrorException("Dbus command failed", e);
+            throw new UnexpectedErrorException("Dbus command failed, maybe signal-cli dbus daemon is already running: "
+                    + e.getMessage(), e);
         }
+
+        logger.info("DBus daemon running on {} bus: {}", busType, DbusConfig.getBusname());
     }
 
     private Thread exportMultiAccountManager(
             final DBusConnection conn, final Manager m, final boolean noReceiveOnStart
     ) {
-        try {
-            final var objectPath = DbusConfig.getObjectPath(m.getSelfNumber());
-            return exportDbusObject(conn, objectPath, m, noReceiveOnStart);
-        } catch (DBusException e) {
-            logger.error("Failed to export object", e);
-            return null;
-        }
+        final var objectPath = DbusConfig.getObjectPath(m.getSelfNumber());
+        return exportDbusObject(conn, objectPath, m, noReceiveOnStart);
     }
 
     private Thread exportDbusObject(
             final DBusConnection conn, final String objectPath, final Manager m, final boolean noReceiveOnStart
-    ) throws DBusException {
+    ) {
         final var signal = new DbusSignalImpl(m, conn, objectPath, noReceiveOnStart);
         final var initThread = new Thread(signal::initObjects);
         initThread.setName("dbus-init");
         initThread.start();
 
-        logger.debug("Exported dbus object: " + objectPath);
-
         return initThread;
     }
 
index b772887b0af48687c39c49ea6115ef3d1d840c55..2585066433e47516617a74a794231a6e43281ad8 100644 (file)
@@ -136,7 +136,7 @@ public class IOUtils {
             logger.info("Listening on socket: " + address);
             postBind(address);
         } catch (IOException e) {
-            throw new IOErrorException("Failed to bind socket: " + e.getMessage(), e);
+            throw new IOErrorException("Failed to bind socket " + address + ": " + e.getMessage(), e);
         }
         return serverChannel;
     }