Better error message on failed coroutines
Add a full error message with traceback if the coroutine_iter_next() function is passed a dead coroutine.
This commit is contained in:
		
							parent
							
								
									a0c8907f71
								
							
						
					
					
						commit
						e0fabca908
					
				| 
						 | 
				
			
			@ -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");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue