Sha256: f3095593bc565998f8b79b12149d15132c5c0527904a535876ebdc963d6ed730

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

module Gaffe
  module Errors
    extend ActiveSupport::Concern

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

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

  protected

    def fetch_exception
      @exception = request.env['action_dispatch.exception']
      @status_code = ActionDispatch::ExceptionWrapper.new(request.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

2 entries across 2 versions & 1 rubygems

Version Path
gaffe-1.2.0 lib/gaffe/errors.rb
gaffe-1.1.0 lib/gaffe/errors.rb