<commit_before># frozen_string_literal: true

class ApplicationController
  class NotAuthorized < StandardError; end

  def flash_and_redirect_back_with_message(exception)
    flash[:error] = exception.message

    if flash[:error].blank?
      case exception
      when NotAuthorized
        flash[:error] = "You are not authorized to perform this action"
      when GitHub::Error, GitHub::Forbidden, GitHub::NotFound
        flash[:error] = "Uh oh, an error has occurred."
      end
    end

    redirect_back(fallback_location: root_path)
  end

  def send_to_statsd(exception)
    GitHubClassroom.statsd.increment("exception.raise")
    raise
  end
end<commit_msg>hound<commit_after># frozen_string_literal: true

class ApplicationController
  class NotAuthorized < StandardError; end

  def flash_and_redirect_back_with_message(exception)
    flash[:error] = exception.message

    if flash[:error].blank?
      case exception
      when NotAuthorized
        flash[:error] = "You are not authorized to perform this action"
      when GitHub::Error, GitHub::Forbidden, GitHub::NotFound
        flash[:error] = "Uh oh, an error has occurred."
      end
    end

    redirect_back(fallback_location: root_path)
  end

  def send_to_statsd(exception)
    GitHubClassroom.statsd.increment("exception.raise")
    raise exception
  end
end
{'fraction_non_alphanumeric': 0.07922272047832586, 'fraction_numerical': 0.0, 'mean_word_length': 3.816546762589928, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5155678', 'n_tokens_mistral': 393, 'n_tokens_neox': 378, 'n_words': 100}