Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/raven/integrations/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ class Rails < ::Rails::Railtie
end

if Raven.configuration.catch_debugged_exceptions
require 'raven/integrations/rails/middleware/debug_exceptions_catcher'
if defined?(::ActionDispatch::DebugExceptions)
require 'raven/integrations/rails/middleware/debug_exceptions_catcher'
::ActionDispatch::DebugExceptions.send(:include, Raven::Rails::Middleware::DebugExceptionsCatcher)
exceptions_class = ::ActionDispatch::DebugExceptions
elsif defined?(::ActionDispatch::ShowExceptions)
require 'raven/integrations/rails/middleware/debug_exceptions_catcher'
::ActionDispatch::ShowExceptions.send(:include, Raven::Rails::Middleware::DebugExceptionsCatcher)
exceptions_class = ::ActionDispatch::ShowExceptions
end
unless exceptions_class.nil?
if RUBY_VERSION.to_f < 2.0
exceptions_class.send(:include, Raven::Rails::Middleware::OldDebugExceptionsCatcher)
else
exceptions_class.send(:prepend, Raven::Rails::Middleware::DebugExceptionsCatcher)
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ module Raven
class Rails
module Middleware
module DebugExceptionsCatcher
def render_exception(env_or_request, exception)
env = env_or_request.respond_to?(:env) ? env_or_request.env : env_or_request
Raven::Rack.capture_exception(exception, env)
ensure
super
end
end

module OldDebugExceptionsCatcher
def self.included(base)
base.send(:alias_method_chain, :render_exception, :raven)
end
Expand Down