1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

"Naked" rescue clauses only catch StandardError subclasses.

Similar to #11497.
This commit is contained in:
thedarkone 2013-08-06 17:03:29 +02:00
parent 3af8a91c38
commit a0907bbdad
2 changed files with 6 additions and 3 deletions

View file

@ -38,7 +38,7 @@ module Rails
resp = @app.call(env)
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
resp
rescue
rescue Exception
finish(request)
raise
ensure

View file

@ -57,11 +57,14 @@ module Rails
end
def test_notification_on_raise
logger = TestLogger.new { raise }
logger = TestLogger.new do
# using an exception class that is not a StandardError subclass on purpose
raise NotImplementedError
end
assert_difference('subscriber.starts.length') do
assert_difference('subscriber.finishes.length') do
assert_raises(RuntimeError) do
assert_raises(NotImplementedError) do
logger.call 'REQUEST_METHOD' => 'GET'
end
end