[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Stack Underflow
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 28 Aug 2002 12:16:20 -0300
>void my_dostring(lua_State *L, const char *cmd)
>{
> int status = luaL_loadbuffer(L, cmd, strlen(cmd), cmd);
>
> if (status == 0)
> status = lua_pcall(L, 0, LUA_MULTRET, 0);
>
> if (status != 0)
> {
> lua_getglobal(L, "_ALERT");
> lua_insert(L, -2);
> lua_call(L, 1, 0);
> }
>}
Just note that calling _ALERT on errors in now a protocol implemented in
lauxlib not in the core nor in lua.c, and it's there for compatibility only.
In other words, you don't *have* to call _ALERT on errors. The official protocol
for handling errors is that lua_load leaves error messages on the stack and
lua_pcall can receive an error handling function as its last argument.
--lhf