From e0fabca9082bb36377606c84c83f53fda01c4d65 Mon Sep 17 00:00:00 2001 From: Robin Malley Date: Sun, 26 Jun 2022 23:05:24 +0000 Subject: [PATCH] Better error message on failed coroutines Add a full error message with traceback if the coroutine_iter_next() function is passed a dead coroutine. --- src/libkore.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libkore.c b/src/libkore.c index 5331020..6430d4e 100644 --- a/src/libkore.c +++ b/src/libkore.c @@ -89,6 +89,11 @@ int coroutine_iter_next(struct co_obj *obj){ lua_rawgeti(L,LUA_REGISTRYINDEX,obj->ref); lua_call(L,1,1); const char *status = luaL_checklstring(L,-1,NULL); + if(strcmp(status,"dead") == 0){ + kore_log(LOG_ERR,"Coroutine was dead when it was passed to coroutine iter next"); + lua_pushstring(L,"Coroutine was dead when passed to coroutine iter next"); + lua_error(L); + } lua_pop(L,lua_gettop(L)); lua_getglobal(L,"coroutine"); lua_getfield(L,-1,"resume");