<commit_before>class ToastController < ApplicationController

  def catch_all

    begin

      @resource = Toast::Resource.build( params, request )

      unless request.headers["LINK"].nil?
        # extract "path_info" from link header
        request.headers["LINK"] =~ /(#{request.protocol + request.host + request.script_name})(.*)/
      end

      render @resource.apply(request.method, request.body.read, request.content_type, $2)

    rescue Toast::ResourceNotFound => e
      return head(:not_found)

    rescue Toast::PayloadInvalid => e
      raise e if Rails.env == "test"
      return render :text => e.message, :status => :forbidden

    rescue Toast::PayloadFormatError => e
      return head(:bad_request)

    rescue Toast::MethodNotAllowed => e
      return head(:method_not_allowed)

    rescue Toast::UnsupportedMediaType => e<commit_msg>should be able to test 'forbidden'<commit_after>class ToastController < ApplicationController

  def catch_all

    begin

      @resource = Toast::Resource.build( params, request )

      unless request.headers["LINK"].nil?
        # extract "path_info" from link header
        request.headers["LINK"] =~ /(#{request.protocol + request.host + request.script_name})(.*)/
      end

      render @resource.apply(request.method, request.body.read, request.content_type, $2)

    rescue Toast::ResourceNotFound => e
      return head(:not_found)

    rescue Toast::PayloadInvalid => e
      return render :text => e.message, :status => :forbidden

    rescue Toast::PayloadFormatError => e
      return head(:bad_request)

    rescue Toast::MethodNotAllowed => e
      return head(:method_not_allowed)

    rescue Toast::UnsupportedMediaType => e
{'fraction_non_alphanumeric': 0.11561032863849766, 'fraction_numerical': 0.0011737089201877935, 'mean_word_length': 3.4285714285714284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '1191775', 'n_tokens_mistral': 490, 'n_tokens_neox': 467, 'n_words': 117}