<commit_before>module Irwi::Extensions::Controllers::WikiPageAttachments

  def add_attachment
    attachment = page_attachment_class.new(params[:wiki_page_attachment])
    attachment.save
    redirect_to url_for(:path => attachment.page.path, :action => :edit)
  end

  def remove_attachment
    attachment = page_attachment_class.find(params[:attachment_id])
    attachment.destroy
    redirect_to url_for(:path => attachment.page.path, :action => :edit)
  end

  protected

  def page_attachment_class
    Irwi.config.page_attachment_class
  end

end<commit_msg>Explicit exception on attachment save error<commit_after>module Irwi::Extensions::Controllers::WikiPageAttachments

  def add_attachment
    attachment = page_attachment_class.new(params[:wiki_page_attachment])
    attachment.save!
    redirect_to url_for(:path => attachment.page.path, :action => :edit)
  end

  def remove_attachment
    attachment = page_attachment_class.find(params[:attachment_id])
    attachment.destroy
    redirect_to url_for(:path => attachment.page.path, :action => :edit)
  end

  protected

  def page_attachment_class
    Irwi.config.page_attachment_class
  end

end
{'fraction_non_alphanumeric': 0.08871662360034453, 'fraction_numerical': 0.0, 'mean_word_length': 5.11578947368421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '413289', 'n_tokens_mistral': 344, 'n_tokens_neox': 337, 'n_words': 64}