Skip to content

Resume a lua thread from rust and make it error inside lua #252

Answered by khvzak
filiptibell asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure that I fully understood the problem, do you have a smaller example?

In general if you throw a error in lua coroutine, it unwinds the stack and there is no function to jump back:

co = coroutine.create(function ()
    coroutine.yield("1")
    error("bla")
    coroutine.yield("2")
end)

-- prints: true 1
print(coroutine.resume(co))
-- prints: false	test.lua:3: bla
print(coroutine.resume(co))
-- prints: false	cannot resume dead coroutine
print(coroutine.resume(co))

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@filiptibell
Comment options

@khvzak
Comment options

Answer selected by filiptibell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants