<commit_before>module Commands
  class CreateConversation
    include Pavlov::Command
    include Util::Validations

    arguments :fact_id, :recipient_usernames

    def validate
      validate_non_empty_list :recipient_usernames, recipient_usernames
    end

    def execute
      conversation = Conversation.new
      recipient_usernames.each do |username|
        user = query :user_by_username, username: username
        raise Pavlov::ValidationError, 'user_not_found' unless user
        conversation.recipients << user
      end

      fact = Fact[fact_id]
      conversation.fact_data_id = fact.data_id
      conversation.save
      conversation
    end
  end
end<commit_msg>Give an error when conversation.save doen'st succeed<commit_after>module Commands
  class CreateConversation
    include Pavlov::Command
    include Util::Validations

    arguments :fact_id, :recipient_usernames

    def validate
      validate_non_empty_list :recipient_usernames, recipient_usernames
    end

    def execute
      conversation = Conversation.new
      recipient_usernames.each do |username|
        user = query :user_by_username, username: username
        raise Pavlov::ValidationError, 'user_not_found' unless user
        conversation.recipients << user
      end

      fact = Fact[fact_id]
      conversation.fact_data_id = fact.data_id
      conversation.save!
      conversation
    end
  end
end
{'fraction_non_alphanumeric': 0.053267045454545456, 'fraction_numerical': 0.0, 'mean_word_length': 3.193452380952381, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4038230', 'n_tokens_mistral': 400, 'n_tokens_neox': 394, 'n_words': 97}