| 1309 | } |
| 1310 | |
| 1311 | static bool do_invoke_cleanup(lua_State *L, int nargs, int errorfun, bool success) |
| 1312 | { |
| 1313 | bool ok = lua_pcall(L, nargs, 0, errorfun) == LUA_OK; |
| 1314 | |
| 1315 | if (!ok) |
| 1316 | { |
| 1317 | // If finalization failed, attach the previous error |
| 1318 | if (lua_istable(L, -1) && !success) |
| 1319 | { |
| 1320 | lua_swap(L); |
| 1321 | lua_setfield(L, -2, "cause"); |
| 1322 | } |
| 1323 | |
| 1324 | success = false; |
| 1325 | } |
| 1326 | |
| 1327 | return success; |
| 1328 | } |
| 1329 | |
| 1330 | int dfhack_cleanup_cont(lua_State *L, int status, lua_KContext) |
| 1331 | { |
no test coverage detected