<commit_before>module ControllerErrorHandling
  extend ActiveSupport::Concern

  included do
    rescue_from StandardError do |exception|
      message = "\n#{exception.class} (#{exception.message}):\n"
      message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
      message << "  " << exception.backtrace.join("\n  ")
      logger.fatal("#{message}\n\n")

      @message = "#{t("error.internal_error")}: #{request.uuid}"
      render "shared/common_error", status: 500, formats: :html
    end

    rescue_from Aclog::Exceptions::Forbidden do |exception|
      @message = t("error.forbidden")
      render "shared/common_error", status: 403, formats: :html
    end

    rescue_from Aclog::Exceptions::UserProtected do |exception|
      @message = t("error.forbidden")
      render "shared/user_forbidden_error", status: 403, formats: :html
    end

    rescue_from ActionController::RoutingError, ActiveRecord::RecordNotFound, Aclog::Exceptions::NotFound do |exception|
      @message = t("error.not_found")
      render "shared/common_error", status: 404, formats: :html
    end

    rescue_from ActionView::MissingTemplate do<commit_msg>rescue from Twitter::Error::NotFound<commit_after>module ControllerErrorHandling
  extend ActiveSupport::Concern

  included do
    rescue_from StandardError do |exception|
      message = "\n#{exception.class} (#{exception.message}):\n"
      message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
      message << "  " << exception.backtrace.join("\n  ")
      logger.fatal("#{message}\n\n")

      @message = "#{t("error.internal_error")}: #{request.uuid}"
      render "shared/common_error", status: 500, formats: :html
    end

    rescue_from Aclog::Exceptions::Forbidden do |exception|
      @message = t("error.forbidden")
      render "shared/common_error", status: 403, formats: :html
    end

    rescue_from Aclog::Exceptions::UserProtected do |exception|
      @message = t("error.forbidden")
      render "shared/user_forbidden_error", status: 403, formats: :html
    end

    rescue_from \
      ActionController::RoutingError,
      ActiveRecord::RecordNotFound,
      Aclog::Exceptions::NotFound,
      Twitter::Error::NotFound do |exception|
      @message = t("error.not_found")
      render "shared/common_error", status: 404, formats: :html
    end

    rescue_from ActionView::MissingTemplate do
{'fraction_non_alphanumeric': 0.12813141683778234, 'fraction_numerical': 0.009856262833675565, 'mean_word_length': 4.053941908713693, 'pattern_counts': {'":': 0, '<': 15, '<?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': '931194', 'n_tokens_mistral': 745, 'n_tokens_neox': 726, 'n_words': 150}