- try {
- var timestamp = signal.sendGroupMessage(messageText, attachments, groupId);
- writer.println("{}", timestamp);
- return;
- } catch (DBusExecutionException e) {
- throw new UnexpectedErrorException("Failed to send group message: " + e.getMessage());
- }
+ try {
+ var results = m.sendMessage(new Message(messageText,
+ attachments,
+ mentions,
+ Optional.ofNullable(quote),
+ Optional.ofNullable(sticker),
+ previews), recipientIdentifiers);
+ outputResult(outputWriter, results);
+ } catch (AttachmentInvalidException | IOException e) {
+ 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) {
+ throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
+ } catch (InvalidStickerException e) {
+ throw new UserErrorException("Failed to send sticker: " + e.getMessage(), e);