提交 a0907bbd 编写于 作者: T thedarkone

"Naked" rescue clauses only catch StandardError subclasses.

Similar to #11497.
上级 3af8a91c
......@@ -38,7 +38,7 @@ def call_app(request, env)
resp = @app.call(env)
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
resp
rescue
rescue Exception
finish(request)
raise
ensure
......
......@@ -57,11 +57,14 @@ def test_notification
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册