Skip to content

Commit 887ed3b

Browse files
committed
Show better error message when sending fails due to missing pre keys
1 parent 3180eba commit 887ed3b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/asamk/signal/commands/SendCommand.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,14 @@ public void handleCommand(
250250
: m.sendMessage(message, recipientIdentifiers, notifySelf);
251251
outputResult(outputWriter, results);
252252
} catch (AttachmentInvalidException | IOException e) {
253-
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
254-
.getSimpleName() + ")", e);
253+
if (e instanceof IOException io && io.getMessage().contains("No prekeys available")) {
254+
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
255+
.getSimpleName() + "), maybe one of the devices of the recipient wasn't online for a while.",
256+
e);
257+
} else {
258+
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
259+
.getSimpleName() + ")", e);
260+
}
255261
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
256262
throw new UserErrorException(e.getMessage());
257263
} catch (UnregisteredRecipientException e) {

0 commit comments

Comments
 (0)