<commit_before>module ExceptionHandler
  class ExceptionController < ApplicationController

    #Response
    #http://www.justinweiss.com/articles/respond-to-without-all-the-pain/
    respond_to :html, :xml, :json

    #Layout
    layout :layout

    #Helpers
    helper ExceptionHandler::Engine.helpers      #-> HELPERS http://stackoverflow.com/questions/9809787/why-is-my-rails-mountable-engine-not-loading-helper-methods-correctly
    include Rails.application.routes.url_helpers #-> ROUTES http://stackoverflow.com/a/6074911/1143732

    ####################
    #      Action      #
    ####################

  	#Show
    #Amend responses in tests
    def show
      @exception = ExceptionHandler::Exception.new request #-> Service Object
      # Need to test validity of JSON responses etc
    end

    ####################
    #   Dependencies   #
    ####################

    protected

    # Status declarations moved to "show" w/ service object
    # Details moved to "View Helper"

    ####################
    #      Layout      #
    ####################

    private

    #Layout
    def layout
      (/^(5[0-9]{2})$/ !~ @exception.code) ? (ExceptionHandler.config.layouts["404"] || nil) : ExceptionHandler.config.layouts["500"] #-> inherits ApplicationController layout (nil means it will use standard layout from ApplicationController)    
    end

    ####################

  end
end<commit_msg>Regex<commit_after>module ExceptionHandler
  class ExceptionController < ApplicationController

    #Response
    #http://www.justinweiss.com/articles/respond-to-without-all-the-pain/
    respond_to :html, :xml, :json

    #Layout
    layout :layout

    #Helpers
    helper ExceptionHandler::Engine.helpers      #-> HELPERS http://stackoverflow.com/questions/9809787/why-is-my-rails-mountable-engine-not-loading-helper-methods-correctly
    include Rails.application.routes.url_helpers #-> ROUTES http://stackoverflow.com/a/6074911/1143732

    ####################
    #      Action      #
    ####################

  	#Show
    #Amend responses in tests
    # Need to test validity of JSON responses etc
    def show
      @exception = ExceptionHandler::Exception.new request #-> Service Object
    end

    ####################
    #   Dependencies   #
    ####################

    protected

    # Status declarations moved to "show" w/ service object
    # Details moved to "View Helper"

    ####################
    #      Layout      #
    ####################

    private

    #Layout
    def layout
      (/^(5[0-9]{2})$/ !~ @exception.code.to_s) ? (ExceptionHandler.config.layouts["404"] || nil) : ExceptionHandler.config.layouts["500"] #-> if not 500, use predefined layout
    end

    ####################

  end
end
{'fraction_non_alphanumeric': 0.19519300801165332, 'fraction_numerical': 0.023670793882010197, 'mean_word_length': 3.039705882352941, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '2493085', 'n_tokens_mistral': 834, 'n_tokens_neox': 741, 'n_words': 163}