diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-05 13:16:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-05 13:16:25 -0300 |
commit | b4d5dff8ec4f1c8a44db66d368e95d359b04aea7 (patch) | |
tree | e87fbd3bcbf8a271429ee31f32eaf928058ab376 /lcorolib.c | |
parent | 14edd364c3abcb758e74c68a2bdd4ddaeefdae2a (diff) | |
download | lua-b4d5dff8ec4f1c8a44db66d368e95d359b04aea7.tar.gz lua-b4d5dff8ec4f1c8a44db66d368e95d359b04aea7.tar.bz2 lua-b4d5dff8ec4f1c8a44db66d368e95d359b04aea7.zip |
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.
Diffstat (limited to 'lcorolib.c')
-rw-r--r-- | lcorolib.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -75,11 +75,8 @@ static int luaB_auxwrap (lua_State *L) { | |||
75 | int r = auxresume(L, co, lua_gettop(L)); | 75 | int r = auxresume(L, co, lua_gettop(L)); |
76 | if (r < 0) { | 76 | if (r < 0) { |
77 | int stat = lua_status(co); | 77 | int stat = lua_status(co); |
78 | if (stat != LUA_OK && stat != LUA_YIELD) { | 78 | if (stat != LUA_OK && stat != LUA_YIELD) |
79 | stat = lua_resetthread(co); /* close variables in case of errors */ | 79 | lua_resetthread(co); /* close variables in case of errors */ |
80 | if (stat != LUA_OK) /* error closing variables? */ | ||
81 | lua_xmove(co, L, 1); /* get new error object */ | ||
82 | } | ||
83 | if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ | 80 | if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ |
84 | luaL_where(L, 1); /* add extra info, if available */ | 81 | luaL_where(L, 1); /* add extra info, if available */ |
85 | lua_insert(L, -2); | 82 | lua_insert(L, -2); |