diff --git a/lib/raven/integrations/rack.rb b/lib/raven/integrations/rack.rb index 50ca1fe50..bee980f02 100644 --- a/lib/raven/integrations/rack.rb +++ b/lib/raven/integrations/rack.rb @@ -60,7 +60,7 @@ def call(env) raise end - error = env['rack.exception'] || env['sinatra.error'] + error = env['rack.exception'] || env['sinatra.error'] || env['action_dispatch.exception'] Raven::Rack.capture_exception(error, env) if error diff --git a/spec/raven/integrations/rack_spec.rb b/spec/raven/integrations/rack_spec.rb index a39eb4f59..d63e3cde3 100644 --- a/spec/raven/integrations/rack_spec.rb +++ b/spec/raven/integrations/rack_spec.rb @@ -46,6 +46,22 @@ 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