Sha256: 8338b6b4ae00f594f850f112e517a2e23bafed13f18cb58b2d9aea8c384fd4c4

Contents?: true

Size: 1.39 KB

Versions: 13

Compression:

Stored size: 1.39 KB

Contents

# core ext
require 'core_ext/proc_ext'

# asset pipeline deps
require 'handlebars_assets'
require 'coffee_script'

# other deps
require 'jquery-rails'
require 'haml'
require 'draper'
require 'exception_notification'

# lib
require 'auto_error/version'
require 'auto_error/config'
require 'auto_error/errors'
require 'auto_error/context_shorthand'
require 'auto_error/helper_context'
require 'auto_error/engine'

module AutoError
  def self.setup!( app_config )
    AutoError::Config.send(:set_defaults)
    app_config.action_dispatch.rescue_responses["AutoError::Errors::Denied"] = :forbidden
    app_config.action_dispatch.rescue_responses["AutoError::Errors::NotFound"] = :not_found

    original_exceptions_app = app_config.exceptions_app || ActionDispatch::PublicExceptions.new(Rails.public_path)
    app_config.exceptions_app = ->(env) do
      puts "Handling exception for #{env['action_controller.instance'].class}"
      controller_class = env['action_controller.instance'].class
      if controller_class.nil? || AutoError.constants.any? { |c| AutoError.const_get(c) == controller_class }
        # do not log/handle exception at all if the error is actually
        # IN auto_error :)
        original_exceptions_app.call(env)
      else
        env['auto_error.original_controller.instance'] = env['action_controller.instance']
        AutoError::ErrorsController.action(:show).call(env)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
auto_error-0.0.18 lib/auto_error.rb
auto_error-0.0.16 lib/auto_error.rb
auto_error-0.0.15 lib/auto_error.rb
auto_error-0.0.14 lib/auto_error.rb
auto_error-0.0.13 lib/auto_error.rb
auto_error-0.0.12 lib/auto_error.rb
auto_error-0.0.10 lib/auto_error.rb
auto_error-0.0.9 lib/auto_error.rb
auto_error-0.0.8 lib/auto_error.rb
auto_error-0.0.7 lib/auto_error.rb
auto_error-0.0.6 lib/auto_error.rb
auto_error-0.0.5 lib/auto_error.rb
auto_error-0.0.4 lib/auto_error.rb