understood, thanks for help.|
> Date: Wed, 10 Dec 2008 11:13:53 +0000
> From: firstname.lastname@example.org
> To: email@example.com
> Subject: Re: how to clear error info from a state?
> 吕游 wrote:
> > if i call luaL_error, the coroutine will stop and then the outer
> > lua_resume will return the error string which pass from luaL_error.
> > my questing is: how to reuse the lua_state?
> > i've tried to clear the stack,push a new chunk and then call
> > lua_resume,but it said:"cannot resume non-suspended coroutine".
> Unless there's some cunning way around it, you'll need to run the
> coroutine's code inside a pcall. When you resume it, the pcall will
> catch the error rather than causing the whole coroutine to terminate.
> (errors/pcall are Lua's exceptions/try/catch mechanism:
> function coroutine_really_main()
> call_some_native_fu nction_that_may_error()
> function coroutine_main()
> if pcall(coroutine_really_main) then
> return coroutine_main() -- restart the coroutine
> David Given