]> nmode's Git Repositories - signal-cli/commitdiff
Show better error message when sending fails due to missing pre keys
authorAsamK <asamk@gmx.de>
Tue, 8 Jul 2025 15:35:17 +0000 (17:35 +0200)
committerAsamK <asamk@gmx.de>
Tue, 8 Jul 2025 15:35:17 +0000 (17:35 +0200)
src/main/java/org/asamk/signal/commands/SendCommand.java

index 39be74ee1eaa4b34a6c5479265c7d6041e8075c6..cce1d21e82eca88f96924d6def135a670619eb78 100644 (file)
@@ -250,8 +250,14 @@ public class SendCommand implements JsonRpcLocalCommand {
                     : m.sendMessage(message, recipientIdentifiers, notifySelf);
             outputResult(outputWriter, results);
         } catch (AttachmentInvalidException | IOException e) {
                     : m.sendMessage(message, recipientIdentifiers, notifySelf);
             outputResult(outputWriter, results);
         } catch (AttachmentInvalidException | IOException e) {
-            throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
-                    .getSimpleName() + ")", e);
+            if (e instanceof IOException io && io.getMessage().contains("No prekeys available")) {
+                throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
+                        .getSimpleName() + "), maybe one of the devices of the recipient wasn't online for a while.",
+                        e);
+            } else {
+                throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
+                        .getSimpleName() + ")", e);
+            }
         } catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
             throw new UserErrorException(e.getMessage());
         } catch (UnregisteredRecipientException e) {
         } catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
             throw new UserErrorException(e.getMessage());
         } catch (UnregisteredRecipientException e) {