Advertisement

lua_pcall always returns zero

Started by March 14, 2011 02:50 PM
-1 comments, last by jblue 13 years, 8 months ago
I am probably doing something wrong, but my current problem is driving me nuts. I am call lua_pcall to loop through my running coroutines and if there is a runtime error the lua instance ends and no error is returned by pcall. Even if I call the error function in lua lua_pcall returns zero.

I call lua_pcall like this.


lua_pushcfunction(luaState , LuaErrorFunc );
lua_getglobal(luaState, "UpdateRoutines" );

if( !lua_isnil(luaState , -1 ) )
{
int numberOfParams = 0;
int status = lua_pcall( luaState , numberOfParams , 0, -(numberOfParams+2) );
if ( status != 0 )
puts( lua_tostring( luaState, -1 ) );
}


thanks

EDIT: I figured it out. I completely forgot that coroutines are protected calls and won't raise errors, but instead return them.

This topic is closed to new replies.

Advertisement