diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-22 10:54:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-22 10:54:25 -0300 |
commit | 0ceada8da92135717d31a3954b5b89a954f9e71a (patch) | |
tree | 99655e44791a11bf805d9f059da7391310618eec /lcorolib.c | |
parent | f9d29b0c442447ebe429bcaad1e2b4bf13c5dc93 (diff) | |
download | lua-0ceada8da92135717d31a3954b5b89a954f9e71a.tar.gz lua-0ceada8da92135717d31a3954b5b89a954f9e71a.tar.bz2 lua-0ceada8da92135717d31a3954b5b89a954f9e71a.zip |
Report last error in closing methods
When there are multiple errors around closing methods, report the
last error instead of the original.
Diffstat (limited to 'lcorolib.c')
-rw-r--r-- | lcorolib.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -75,8 +75,11 @@ 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) { /* error? */ | 76 | if (r < 0) { /* error? */ |
77 | int stat = lua_status(co); | 77 | int stat = lua_status(co); |
78 | if (stat != LUA_OK && stat != LUA_YIELD) /* error in the coroutine? */ | 78 | if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ |
79 | lua_resetthread(co); /* close its tbc variables */ | 79 | stat = lua_resetthread(co); /* close its tbc variables */ |
80 | lua_assert(stat != LUA_OK); | ||
81 | lua_xmove(co, L, 1); /* copy error message */ | ||
82 | } | ||
80 | if (stat != LUA_ERRMEM && /* not a memory error and ... */ | 83 | if (stat != LUA_ERRMEM && /* not a memory error and ... */ |
81 | lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ | 84 | lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ |
82 | luaL_where(L, 1); /* add extra info, if available */ | 85 | luaL_where(L, 1); /* add extra info, if available */ |