Sha256: 23330395342d2c18ec9386e2d7204601d0960380dc5f7697840142208fa43fc3

Contents?: true

Size: 802 Bytes

Versions: 3

Compression:

Stored size: 802 Bytes

Contents

module Gaffe
  module Errors
    extend ActiveSupport::Concern

    included do
      before_filter :fetch_exception, only: %w(show)
      before_filter :append_view_paths
      layout 'error'
    end

    def show
      begin
        render "errors/#{@rescue_response}", status: @status_code
      rescue ActionView::MissingTemplate
        render "errors/internal_server_error", status: 500
      end
    end

  protected

    def fetch_exception
      @exception = env['action_dispatch.exception']
      @status_code = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
      @rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
    end

  private

    def append_view_paths
      append_view_path Gaffe.root.join('app/views')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gaffe-1.0.1 lib/gaffe/errors.rb
gaffe-1.0 lib/gaffe/errors.rb
gaffe-0.2.1 lib/gaffe/errors.rb