[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Error handling in coroutines
- From: "Patrick Donnelly" <batrick.donnelly@...>
- Date: Thu, 27 Sep 2007 19:11:30 -0600
On 9/27/07, Senko, Michael <michael.senko@thermofisher.com> wrote:
> The problem I have is with error handling. I catch syntax errors just fine
> with the return value from luaL_loadbuffer(). Its execution errors that I
> have trouble with. Based upon PIL, I would expect errors to cause
> lua_resume() to return an error code in the same fashion as lua_pcall().
> What I'm seeing instead is that I get a panic ("unprotected error in call to
> Lua API") which halts my application.
According to the manual, lua_resume() does return an error code:
http://www.lua.org/manual/5.1/manual.html#lua_resume
What I believe what happened was you tried to resume the coroutine
when there was an error previously. Perhaps you need to check if there
was an error, and if there was, print the value at the top of the
stack (the error message). Review:
http://www.lua.org/manual/5.1/manual.html#lua_pcall
for more on error messages.
HTH,
--
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."
-Will Durant