module AutoError
Constants
- VERSION
Public Class Methods
setup!( app_config )
click to toggle source
# File lib/auto_error.rb, line 23 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