]> nmode's Git Repositories - signal-cli/commitdiff
Print stack trace of exception causes in verbose mode
authorAsamK <asamk@gmx.de>
Wed, 8 Sep 2021 18:38:24 +0000 (20:38 +0200)
committerAsamK <asamk@gmx.de>
Wed, 8 Sep 2021 18:38:24 +0000 (20:38 +0200)
32 files changed:
src/main/java/org/asamk/signal/App.java
src/main/java/org/asamk/signal/Main.java
src/main/java/org/asamk/signal/commands/AddDeviceCommand.java
src/main/java/org/asamk/signal/commands/BlockCommand.java
src/main/java/org/asamk/signal/commands/DaemonCommand.java
src/main/java/org/asamk/signal/commands/GetUserStatusCommand.java
src/main/java/org/asamk/signal/commands/JoinGroupCommand.java
src/main/java/org/asamk/signal/commands/LinkCommand.java
src/main/java/org/asamk/signal/commands/ListDevicesCommand.java
src/main/java/org/asamk/signal/commands/QuitGroupCommand.java
src/main/java/org/asamk/signal/commands/ReceiveCommand.java
src/main/java/org/asamk/signal/commands/RegisterCommand.java
src/main/java/org/asamk/signal/commands/RemoteDeleteCommand.java
src/main/java/org/asamk/signal/commands/RemoveDeviceCommand.java
src/main/java/org/asamk/signal/commands/RemovePinCommand.java
src/main/java/org/asamk/signal/commands/SendCommand.java
src/main/java/org/asamk/signal/commands/SendContactsCommand.java
src/main/java/org/asamk/signal/commands/SendReactionCommand.java
src/main/java/org/asamk/signal/commands/SendSyncRequestCommand.java
src/main/java/org/asamk/signal/commands/SetPinCommand.java
src/main/java/org/asamk/signal/commands/UnblockCommand.java
src/main/java/org/asamk/signal/commands/UnregisterCommand.java
src/main/java/org/asamk/signal/commands/UpdateAccountCommand.java
src/main/java/org/asamk/signal/commands/UpdateContactCommand.java
src/main/java/org/asamk/signal/commands/UpdateGroupCommand.java
src/main/java/org/asamk/signal/commands/UpdateProfileCommand.java
src/main/java/org/asamk/signal/commands/UploadStickerPackCommand.java
src/main/java/org/asamk/signal/commands/VerifyCommand.java
src/main/java/org/asamk/signal/commands/exceptions/CommandException.java
src/main/java/org/asamk/signal/commands/exceptions/IOErrorException.java
src/main/java/org/asamk/signal/commands/exceptions/UnexpectedErrorException.java
src/main/java/org/asamk/signal/util/ErrorUtils.java

index 1ff1a9094447739848e75f374b769bcff83b871e..4aa510d61d2d967fd96df08d33c8d609dc27ba81 100644 (file)
@@ -16,6 +16,7 @@ import org.asamk.signal.commands.ProvisioningCommand;
 import org.asamk.signal.commands.RegistrationCommand;
 import org.asamk.signal.commands.SignalCreator;
 import org.asamk.signal.commands.exceptions.CommandException;
+import org.asamk.signal.commands.exceptions.IOErrorException;
 import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
 import org.asamk.signal.commands.exceptions.UserErrorException;
 import org.asamk.signal.manager.Manager;
@@ -225,7 +226,7 @@ public class App {
                     + e.getMessage()
                     + " ("
                     + e.getClass().getSimpleName()
-                    + ")");
+                    + ")", e);
         }
         try (var m = manager) {
             command.handleCommand(ns, m);
@@ -299,20 +300,19 @@ public class App {
         } catch (NotRegisteredException e) {
             throw new UserErrorException("User " + username + " is not registered.");
         } catch (Throwable e) {
-            logger.debug("Loading state file failed", e);
             throw new UnexpectedErrorException("Error loading state file for user "
                     + username
                     + ": "
                     + e.getMessage()
                     + " ("
                     + e.getClass().getSimpleName()
-                    + ")");
+                    + ")", e);
         }
 
         try {
             manager.checkAccountState();
         } catch (IOException e) {
-            throw new UnexpectedErrorException("Error while checking account " + username + ": " + e.getMessage());
+            throw new IOErrorException("Error while checking account " + username + ": " + e.getMessage(), e);
         }
 
         return manager;
@@ -337,7 +337,7 @@ public class App {
             }
         } catch (DBusException | IOException e) {
             logger.error("Dbus client failed", e);
-            throw new UnexpectedErrorException("Dbus client failed");
+            throw new UnexpectedErrorException("Dbus client failed", e);
         }
     }
 
index e07475003146f5af717598d89b01b92314ee41d2..fc63b89e7f20ff1694161b1694ee41c57e6de7d6 100644 (file)
@@ -40,7 +40,8 @@ public class Main {
         installSecurityProviderWorkaround();
 
         // Configuring the logger needs to happen before any logger is initialized
-        configureLogging(isVerbose(args));
+        final var isVerbose = isVerbose(args);
+        configureLogging(isVerbose);
 
         var parser = App.buildArgumentParser();
 
@@ -51,6 +52,9 @@ public class Main {
             new App(ns).init();
         } catch (CommandException e) {
             System.err.println(e.getMessage());
+            if (isVerbose && e.getCause() != null) {
+                e.getCause().printStackTrace();
+            }
             status = getStatusForError(e);
         }
         System.exit(status);
index 1616a01ff1f01a828d492409c33a1d1a290a2722..e609ec1e074b73935f7c5b168c2e6d2565aeb9ae 100644 (file)
@@ -42,12 +42,12 @@ public class AddDeviceCommand implements JsonRpcLocalCommand {
             m.addDeviceLink(new URI(ns.getString("uri")));
         } catch (IOException e) {
             logger.error("Add device link failed", e);
-            throw new IOErrorException("Add device link failed");
+            throw new IOErrorException("Add device link failed", e);
         } catch (URISyntaxException e) {
             throw new UserErrorException("Device link uri has invalid format: " + e.getMessage());
         } catch (InvalidKeyException e) {
             logger.error("Add device link failed", e);
-            throw new UnexpectedErrorException("Add device link failed.");
+            throw new UnexpectedErrorException("Add device link failed.", e);
         }
     }
 }
index 77a622b1b8fcdc4f4d1034cdbb15c44ea163d3d8..5394022ecbe53acc77522f3b482857d769974a22 100644 (file)
@@ -43,7 +43,7 @@ public class BlockCommand implements JsonRpcLocalCommand {
             } catch (NotMasterDeviceException e) {
                 throw new UserErrorException("This command doesn't work on linked devices.");
             } catch (IOException e) {
-                throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage());
+                throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage(), e);
             }
         }
 
@@ -55,7 +55,7 @@ public class BlockCommand implements JsonRpcLocalCommand {
                 } catch (GroupNotFoundException e) {
                     logger.warn("Group not found {}: {}", groupId.toBase64(), e.getMessage());
                 } catch (IOException e) {
-                    throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage());
+                    throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage(), e);
                 }
             }
         }
index 0591486c931f80b85450ae136fd74b24a6cbaeff..4a322b993e82b4d2870156be2368ecceea35f7fe 100644 (file)
@@ -75,7 +75,7 @@ public class DaemonCommand implements MultiLocalCommand {
             }
         } catch (DBusException | IOException e) {
             logger.error("Dbus command failed", e);
-            throw new UnexpectedErrorException("Dbus command failed");
+            throw new UnexpectedErrorException("Dbus command failed", e);
         }
     }
 
@@ -113,7 +113,7 @@ public class DaemonCommand implements MultiLocalCommand {
             signalControl.run();
         } catch (DBusException | IOException e) {
             logger.error("Dbus command failed", e);
-            throw new UnexpectedErrorException("Dbus command failed");
+            throw new UnexpectedErrorException("Dbus command failed", e);
         }
     }
 
index cf4be085cfb9031068da26ff7e3f861a8f3d4be1..316f59b15ca3fb0a773b665949ca7d4900d1a78f 100644 (file)
@@ -43,8 +43,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
         try {
             registered = m.areUsersRegistered(new HashSet<>(ns.getList("recipient")));
         } catch (IOException e) {
-            logger.debug("Failed to check registered users", e);
-            throw new IOErrorException("Unable to check if users are registered");
+            throw new IOErrorException("Unable to check if users are registered", e);
         }
 
         // Output
index 8c1b9fb25764c96f54dafe6b1450e78f498a43fe..f55858811078583042656ed4661379dc63de1dce 100644 (file)
@@ -78,10 +78,10 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
                     + e.getMessage()
                     + " ("
                     + e.getClass().getSimpleName()
-                    + ")");
+                    + ")", e);
         } catch (DBusExecutionException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         } catch (GroupLinkNotActiveException e) {
             throw new UserErrorException("Group link is not valid: " + e.getMessage());
         }
index 9fcaf04d03b93f01bb3713c40f89a88932a371fe..fbc0330062c3bef1418a3a42bdcd85f4d4ceda3c 100644 (file)
@@ -49,7 +49,7 @@ public class LinkCommand implements ProvisioningCommand {
         } catch (TimeoutException e) {
             throw new UserErrorException("Link request timed out, please try again.");
         } catch (IOException e) {
-            throw new IOErrorException("Link request error: " + e.getMessage());
+            throw new IOErrorException("Link request error: " + e.getMessage(), e);
         } catch (UserAlreadyExists e) {
             throw new UserErrorException("The user "
                     + e.getUsername()
index 40f30681d399b0e14f229d41fec27668580ee10b..ad0d3531503c1122abfb1a157b5a06835f58ddca 100644 (file)
@@ -40,8 +40,7 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
         try {
             devices = m.getLinkedDevices();
         } catch (IOException e) {
-            logger.debug("Failed to get linked devices", e);
-            throw new IOErrorException("Failed to get linked devices: " + e.getMessage());
+            throw new IOErrorException("Failed to get linked devices: " + e.getMessage(), e);
         }
 
         if (outputWriter instanceof PlainTextWriter) {
@@ -71,10 +70,7 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
         public final long lastSeenTimestamp;
 
         private JsonDevice(
-                final long id,
-                final String name,
-                final long createdTimestamp,
-                final long lastSeenTimestamp
+                final long id, final String name, final long createdTimestamp, final long lastSeenTimestamp
         ) {
             this.id = id;
             this.name = name;
index c64d19cc2a95dd2d04d78185fb24a839b74ad4f9..67a6596b4a13e9b31b3092ecf02beb6ee870398d 100644 (file)
@@ -70,7 +70,7 @@ public class QuitGroupCommand implements JsonRpcLocalCommand {
                     + e.getMessage()
                     + " ("
                     + e.getClass().getSimpleName()
-                    + ")");
+                    + ")", e);
         } catch (GroupNotFoundException e) {
             throw new UserErrorException("Failed to send to group: " + e.getMessage());
         } catch (LastGroupAdminException e) {
index f248d6628d9a34fa6cf988e840862a04dcb2bcbd..62b3164bfbf7968fee5c07cf2fee0b13a48fab1c 100644 (file)
@@ -126,7 +126,7 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
             }
         } catch (DBusException e) {
             logger.error("Dbus client failed", e);
-            throw new UnexpectedErrorException("Dbus client failed");
+            throw new UnexpectedErrorException("Dbus client failed", e);
         }
         while (true) {
             try {
@@ -157,7 +157,7 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
                     ignoreAttachments,
                     handler);
         } catch (IOException e) {
-            throw new IOErrorException("Error while receiving messages: " + e.getMessage());
+            throw new IOErrorException("Error while receiving messages: " + e.getMessage(), e);
         }
     }
 }
index dad692d213b35516c6954a0f7008a845404bd836..96530889a10f902b87bfc156af18b68621a5e27c 100644 (file)
@@ -49,7 +49,7 @@ public class RegisterCommand implements RegistrationCommand {
             }
             throw new UserErrorException(message);
         } catch (IOException e) {
-            throw new IOErrorException("Request verify error: " + e.getMessage());
+            throw new IOErrorException("Request verify error: " + e.getMessage(), e);
         }
     }
 }
index 6e1e92f7b2058af5041f47b478c5d7e695e49023..7d7067c4397607123020443442d6493d821b2cfb 100644 (file)
@@ -65,7 +65,7 @@ public class RemoteDeleteCommand implements DbusCommand, JsonRpcLocalCommand {
             throw new UserErrorException(e.getMessage());
         } catch (IOException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         }
     }
 
@@ -106,7 +106,7 @@ public class RemoteDeleteCommand implements DbusCommand, JsonRpcLocalCommand {
             throw new UserErrorException("Failed to send to group: " + e.getMessage());
         } catch (DBusExecutionException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         }
     }
 
index 1f47e2b30486a39a4cbb04f5ced8103816dd72eb..d67cc5eafda8e126363268cb500ab1a177daddf5 100644 (file)
@@ -34,7 +34,7 @@ public class RemoveDeviceCommand implements JsonRpcLocalCommand {
             int deviceId = ns.getInt("device-id");
             m.removeLinkedDevices(deviceId);
         } catch (IOException e) {
-            throw new IOErrorException("Error while removing device: " + e.getMessage());
+            throw new IOErrorException("Error while removing device: " + e.getMessage(), e);
         }
     }
 }
index 42ca88804dd7df97dc54e9ec794d7686a068a79a..d1ad276ab516d5861eaec633b0ba93a3ea186a5a 100644 (file)
@@ -32,9 +32,9 @@ public class RemovePinCommand implements JsonRpcLocalCommand {
         try {
             m.setRegistrationLockPin(Optional.absent());
         } catch (UnauthenticatedResponseException e) {
-            throw new UnexpectedErrorException("Remove pin failed with unauthenticated response: " + e.getMessage());
+            throw new UnexpectedErrorException("Remove pin failed with unauthenticated response: " + e.getMessage(), e);
         } catch (IOException e) {
-            throw new IOErrorException("Remove pin error: " + e.getMessage());
+            throw new IOErrorException("Remove pin error: " + e.getMessage(), e);
         }
     }
 }
index 7ab445fc378bb914843095ae94f0d106a5b138f2..1973b1a106ca31a40de20574ec41b7b5c1444b17 100644 (file)
@@ -86,7 +86,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
                 return;
             } catch (IOException e) {
                 throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                        .getSimpleName() + ")");
+                        .getSimpleName() + ")", e);
             }
         }
 
@@ -110,7 +110,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
             ErrorUtils.handleSendMessageResults(results.getResults());
         } catch (AttachmentInvalidException | IOException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         } catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
             throw new UserErrorException(e.getMessage());
         }
@@ -147,7 +147,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
                         .getSimpleName() + ")");
             } catch (DBusExecutionException e) {
                 throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                        .getSimpleName() + ")");
+                        .getSimpleName() + ")", e);
             }
         }
 
@@ -176,7 +176,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
                 outputResult(outputWriter, timestamp);
                 return;
             } catch (DBusExecutionException e) {
-                throw new UnexpectedErrorException("Failed to send group message: " + e.getMessage());
+                throw new UnexpectedErrorException("Failed to send group message: " + e.getMessage(), e);
             }
         }
 
@@ -189,7 +189,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
                 throw new UntrustedKeyErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
                         .getSimpleName() + ")");
             } catch (DBusExecutionException e) {
-                throw new UnexpectedErrorException("Failed to send note to self message: " + e.getMessage());
+                throw new UnexpectedErrorException("Failed to send note to self message: " + e.getMessage(), e);
             }
         }
 
@@ -203,7 +203,7 @@ public class SendCommand implements DbusCommand, JsonRpcLocalCommand {
                     .getSimpleName() + ")");
         } catch (DBusExecutionException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         }
     }
 
index 07dca322f3a8dff0950d3e42479431e5ac6ab993..1cc59bff2f5d28d7ea39cb6960bb6e4f7f2cafd8 100644 (file)
@@ -29,7 +29,7 @@ public class SendContactsCommand implements JsonRpcLocalCommand {
         try {
             m.sendContacts();
         } catch (IOException e) {
-            throw new IOErrorException("SendContacts error: " + e.getMessage());
+            throw new IOErrorException("SendContacts error: " + e.getMessage(), e);
         }
     }
 }
index 11a16b2e8a3c0aa04c43704faecad09c3fdd45ab..338e70ac8500f0d17461a7dc9a079a3256ceb5d1 100644 (file)
@@ -81,7 +81,7 @@ public class SendReactionCommand implements DbusCommand, JsonRpcLocalCommand {
             throw new UserErrorException(e.getMessage());
         } catch (IOException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         }
     }
 
@@ -129,7 +129,7 @@ public class SendReactionCommand implements DbusCommand, JsonRpcLocalCommand {
             throw new UserErrorException("Failed to send to group: " + e.getMessage());
         } catch (DBusExecutionException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         }
     }
 
index e9a2f94efbb5601f45a1822ef38006158381087e..aef2d4106b470f7487b8f7381ecf7d9bf9be1c74 100644 (file)
@@ -29,7 +29,7 @@ public class SendSyncRequestCommand implements JsonRpcLocalCommand {
         try {
             m.requestAllSyncData();
         } catch (IOException e) {
-            throw new IOErrorException("Request sync data error: " + e.getMessage());
+            throw new IOErrorException("Request sync data error: " + e.getMessage(), e);
         }
     }
 }
index 3636a8b1e97ec64f6afdc1240183d3d0ded876b9..ec4a0e3b13f07a9f875b7ffa1347639928c9b362 100644 (file)
@@ -35,9 +35,10 @@ public class SetPinCommand implements JsonRpcLocalCommand {
             var registrationLockPin = ns.getString("pin");
             m.setRegistrationLockPin(Optional.of(registrationLockPin));
         } catch (UnauthenticatedResponseException e) {
-            throw new UnexpectedErrorException("Set pin error failed with unauthenticated response: " + e.getMessage());
+            throw new UnexpectedErrorException("Set pin error failed with unauthenticated response: " + e.getMessage(),
+                    e);
         } catch (IOException e) {
-            throw new IOErrorException("Set pin error: " + e.getMessage());
+            throw new IOErrorException("Set pin error: " + e.getMessage(), e);
         }
     }
 }
index 46bd9daabb0afb8c37efbda22234d435828d04b1..812065bc558fb05da9c3103eb8de318bd1c8ae5c 100644 (file)
@@ -42,7 +42,7 @@ public class UnblockCommand implements JsonRpcLocalCommand {
             } catch (NotMasterDeviceException e) {
                 throw new UserErrorException("This command doesn't work on linked devices.");
             } catch (IOException e) {
-                throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage());
+                throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e);
             }
         }
 
@@ -53,7 +53,7 @@ public class UnblockCommand implements JsonRpcLocalCommand {
             } catch (GroupNotFoundException e) {
                 logger.warn("Unknown group id: {}", groupId);
             } catch (IOException e) {
-                throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage());
+                throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e);
             }
         }
     }
index cf09c48012514beb84dd1caa581af954742a6a76..6026004611c3cde3d2d047576f2b2fbfe779edcf 100644 (file)
@@ -37,7 +37,7 @@ public class UnregisterCommand implements LocalCommand {
                 m.unregister();
             }
         } catch (IOException e) {
-            throw new IOErrorException("Unregister error: " + e.getMessage());
+            throw new IOErrorException("Unregister error: " + e.getMessage(), e);
         }
     }
 }
index 600a38c4c85d6a86d16c17185add9fcaaab23ed4..e8211aeeac19a24abc6d8231c37b7a5d2b7e4292 100644 (file)
@@ -31,7 +31,7 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
         try {
             m.updateAccountAttributes(deviceName);
         } catch (IOException e) {
-            throw new IOErrorException("UpdateAccount error: " + e.getMessage());
+            throw new IOErrorException("UpdateAccount error: " + e.getMessage(), e);
         }
     }
 }
index 8b9f9aa5db4543ec2ac8916da2f1b3854a2a3b58..6c2916ebfdbafe378f464828c5429eaa3bbbd4c7 100644 (file)
@@ -46,7 +46,7 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
                 m.setContactName(recipient, name);
             }
         } catch (IOException e) {
-            throw new IOErrorException("Update contact error: " + e.getMessage());
+            throw new IOErrorException("Update contact error: " + e.getMessage(), e);
         } catch (NotMasterDeviceException e) {
             throw new UserErrorException("This command doesn't work on linked devices.");
         }
index 6df70ac2e3416104bfc9a1b805ada8a3ca898c12..b0269894ebdf7ae4d91ef85607971b6050c9d417 100644 (file)
@@ -175,7 +175,7 @@ public class UpdateGroupCommand implements DbusCommand, JsonRpcLocalCommand {
             throw new UserErrorException(e.getMessage());
         } catch (IOException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         }
     }
 
@@ -212,7 +212,7 @@ public class UpdateGroupCommand implements DbusCommand, JsonRpcLocalCommand {
             throw new UserErrorException("Failed to add avatar attachment for group\": " + e.getMessage());
         } catch (DBusExecutionException e) {
             throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")");
+                    .getSimpleName() + ")", e);
         }
     }
 
index 15c29e85373b3cc048016230cda6877a1df2bc79..f6dcb30eaa4d212ec01a5c61c4024e3639ad6a4a 100644 (file)
@@ -51,7 +51,7 @@ public class UpdateProfileCommand implements JsonRpcLocalCommand {
         try {
             m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile);
         } catch (IOException e) {
-            throw new IOErrorException("Update profile error: " + e.getMessage());
+            throw new IOErrorException("Update profile error: " + e.getMessage(), e);
         }
     }
 }
index 7af6fed821c63fc56c21372195d2e034dcfe58cf..53b64b8c64dfd477da46e752ff315fd568edecde 100644 (file)
@@ -50,7 +50,7 @@ public class UploadStickerPackCommand implements JsonRpcLocalCommand {
                 writer.write(Map.of("url", url));
             }
         } catch (IOException e) {
-            throw new IOErrorException("Upload error (maybe image size too large):" + e.getMessage());
+            throw new IOErrorException("Upload error (maybe image size too large):" + e.getMessage(), e);
         } catch (StickerPackInvalidException e) {
             throw new UserErrorException("Invalid sticker pack: " + e.getMessage());
         }
index 2f9388ba120ef2286dd16aa45495cb8ca2422814..b7fffcd23ca5c663c2abb2247c2652121483ad78 100644 (file)
@@ -44,9 +44,9 @@ public class VerifyCommand implements RegistrationCommand {
         } catch (KeyBackupServicePinException e) {
             throw new UserErrorException("Verification failed! Invalid pin, tries remaining: " + e.getTriesRemaining());
         } catch (KeyBackupSystemNoDataException e) {
-            throw new UnexpectedErrorException("Verification failed! No KBS data.");
+            throw new UnexpectedErrorException("Verification failed! No KBS data.", e);
         } catch (IOException e) {
-            throw new IOErrorException("Verify error: " + e.getMessage());
+            throw new IOErrorException("Verify error: " + e.getMessage(), e);
         }
     }
 }
index c82ef5423e48608ec7e7681be9df76462031dc95..bae7af43aa1d8c2b55fa4a3b92fb7ce4bdf38a2d 100644 (file)
@@ -5,4 +5,8 @@ public class CommandException extends Exception {
     public CommandException(final String message) {
         super(message);
     }
+
+    public CommandException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
 }
index e405600c76c3274fe9d1d0189455c32d20bc642f..91436693bdf10572a2b6a91a4af9e4079f45cd02 100644 (file)
@@ -1,8 +1,10 @@
 package org.asamk.signal.commands.exceptions;
 
+import java.io.IOException;
+
 public final class IOErrorException extends CommandException {
 
-    public IOErrorException(final String message) {
-        super(message);
+    public IOErrorException(final String message, IOException cause) {
+        super(message, cause);
     }
 }
index b6f231df593e799a39764592097755bc9b89e781..7e893d35447b3cb297c382e027c43f85316aa763 100644 (file)
@@ -2,7 +2,7 @@ package org.asamk.signal.commands.exceptions;
 
 public final class UnexpectedErrorException extends CommandException {
 
-    public UnexpectedErrorException(final String message) {
-        super(message);
+    public UnexpectedErrorException(final String message, final Throwable cause) {
+        super(message, cause);
     }
 }
index 8a3de142f7409e0e299be90369c080db580edbe9..39e32198a06dfa3b93c005cfec6d4ed2eb30173f 100644 (file)
@@ -88,6 +88,6 @@ public class ErrorUtils {
         for (var error : errors) {
             message.append(error).append("\n");
         }
-        throw new IOErrorException(message.toString());
+        throw new IOErrorException(message.toString(), null);
     }
 }