[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Tracebacks in coroutines
- From: RLake@...
- Date: Sun, 7 Mar 2004 02:21:22 +0000
It was good to hear that this will be
addressed in the next version.
In the meantime, the following appears
to work; no warranties, do not use under the influence of heavy machinery,
etc.
In ldebug.c, replace the definition
of luaG_errormsg with the following:
void luaG_errormsg (lua_State
*L) {
const TObject *errfunc;
if (L->errfunc != 0)
{ /* is there an error handling function? */
errfunc = restorestack(L,
L->errfunc);
} else {
errfunc = luaH_getstr(hvalue(gt(L)),
luaS_new(L, "_TRACEBACK"));
}
if (ttisfunction(errfunc)) {
setobjs2s(L->top, L->top
- 1); /* move argument */
setobj2s(L->top - 1,
errfunc); /* push function */
incr_top(L);
luaD_call(L, L->top
- 2, 1); /* call it */
}
luaD_throw(L, LUA_ERRRUN);
}
Of course, all this does is generate
a traceback; it is still necessary to check the return from coroutine.resume/lua_resume.