Multiple errors in '__toclose' report the first one
When there are multiple errors when closing objects, the error reported by the protected call is the first one, for two reasons: First, other errors may be caused by this one; second, the first error is handled in the original execution context, and therefore has the full traceback.
This commit is contained in:
@@ -163,15 +163,23 @@ do
|
||||
assert(not X and coroutine.status(co) == "dead")
|
||||
|
||||
-- error closing a coroutine
|
||||
local x = 0
|
||||
co = coroutine.create(function()
|
||||
local <toclose> y = func2close(function (self,err)
|
||||
if (err ~= 111) then os.exit(false) end -- should not happen
|
||||
x = 200
|
||||
error(200)
|
||||
end)
|
||||
local <toclose> x = func2close(function (self, err)
|
||||
assert(err == nil); error(111)
|
||||
end)
|
||||
coroutine.yield()
|
||||
end)
|
||||
coroutine.resume(co)
|
||||
assert(x == 0)
|
||||
local st, msg = coroutine.close(co)
|
||||
assert(not st and coroutine.status(co) == "dead" and msg == 111)
|
||||
assert(st == false and coroutine.status(co) == "dead" and msg == 111)
|
||||
assert(x == 200)
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user