Skip to content
Closed
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
2 changes: 1 addition & 1 deletion lib/raven/integrations/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def call(env)
raise
end

error = env['rack.exception'] || env['sinatra.error'] || env['action_dispatch.exception']
error = env['rack.exception'] || env['sinatra.error']

Raven::Rack.capture_exception(error, env) if error

Expand Down
5 changes: 5 additions & 0 deletions lib/raven/integrations/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class Rails < ::Rails::Railtie
::ActionDispatch::ShowExceptions.send(:include, Raven::Rails::Middleware::DebugExceptionsCatcher)
end
end

if defined?(::ActionDispatch::PublicExceptions)
require 'raven/integrations/rails/middleware/public_exceptions_catcher'
::ActionDispatch::PublicExceptions.send(:include, Raven::Rails::Middleware::PublicExceptionsCatcher)
end
end

rake_tasks do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Raven
class Rails
module Middleware
module PublicExceptionsCatcher
def self.included(base)
base.send(:alias_method_chain, :call, :raven)
end

def call_with_raven(env)
Raven::Rack.capture_exception(env['action_dispatch.exception'], env)
call_without_raven(env)
end
end
end
end
end
18 changes: 1 addition & 17 deletions spec/raven/integrations/rack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,6 @@
stack.call(env)
end

it 'should capture rails errors when ActionDispatch::ShowExceptions is enabled' do
exception = build_exception
env = {}

expect(Raven::Rack).to receive(:capture_exception).with(exception, env)

app = lambda do |e|
e['action_dispatch.exception'] = exception
[200, {}, ['okay']]
end

stack = Raven::Rack.new(app)

stack.call(env)
end

it 'should clear context after app is called' do
Raven::Context.current.tags[:environment] = :test

Expand Down Expand Up @@ -102,7 +86,7 @@
end

stack = Raven::Rack.new(Rack::Lint.new(app))
expect { stack.call(env) }.to_not raise_error(Rack::Lint::LintError)
expect { stack.call(env) }.to_not raise_error
end

end