[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Throwing an error on a yielded thread
- From: esmil@...
- Date: Wed, 3 Dec 2008 02:02:47 +0100 (CET)
> On Tuesday 02, email@example.com wrote:
>> This is all very good and works fine except for one situation: Say a
>> thread is yielded while waiting for data, but in the meantime the
>> connection is closed or some other error happens and I want to
>> immediately stop execution of the thread and clean up the data
>> associated with it. The problem is that now I can't get to the data I
>> pushed to the stack before starting it, so what I really need is some
>> way to resume the thread, but throw an error immediately. I've been
>> looking through the manual several times now, but I can't figure out
>> how to do that. Am I just blind or is there a good reason this isn't
> You should be able to just throw an error on the yielded thread without
> resuming it by calling 'lua_error' or 'luaL_error' on the 'lua_State'
> Robert G. Jakabosky
No, I tried that already. It just makes Lua print
PANIC: unprotected error in call to Lua API (<error msg>)
followed by an exit(EXIT_FAILURE); call. This isn't exactly what I
wanted. I only want to put the Lua thread in the error state as if
the Lua code had called error(), not exit the whole program.