Sha256: 27e137e6a947e84b09e1a5e57ad7f9d72c4a74e81a04c1b0d2e4b377bcc7f63a

Contents?: true

Size: 698 Bytes

Versions: 4

Compression:

Stored size: 698 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
      render "errors/#{@rescue_response}", status: @status_code
    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 File.expand_path('../../../app/views', __FILE__)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gaffe-0.2 lib/gaffe/errors.rb
gaffe-0.1.2 lib/gaffe/errors.rb
gaffe-0.1.1 lib/gaffe/errors.rb
gaffe-0.1 lib/gaffe/errors.rb