lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> >If I start my lua script using lua_pcall() I can set an error handler and
> >that way get stack dumps etc instead of just the error message itself.
> >However, if I use coroutines and therefore start the scripts using
> >lua_resume I do not have this possibility in the call.
> >
> >So how do I set an error handler when using lua_resume?  Especially as I
> >can't do it through another pcall inside the script either.
> Start your interaction with Lua with lua_cpcall, as lua.c does.

Ehh.. I can't see how that will do the trick? I would still have to do a
lua_pcall or a lua_resume (without error handler)
inside the given cfunc to start the script itself, and then I still get the
"attempt to yield across metamethod/C-call boundary" error when yielding.

I also noticed a
    lua_assert(L->errfunc == 0 && L->nCcalls == 0);
in lua_resume, so I guess I can't/shouldn't set an error function before
resuming. But how can I add an error function "inside" the resume without
doing it in a new c function causing the above error?

As it stands now I can run one-shot scripts with proper error handling
started by lua_pcall, but for scripts running over time (by being called
every timestep by the c script engine using lua_resume and then yielding
when done for that timestep),  I have no other error handling than the
original error message itself.

And, if it's not possible with the given lua implementation, why can't I
just modify lua_resume to include an error handler? (there must be some
reason for that assertion...)

Henrik Münther