Log In  


I'm loving coroutines -- they make it so easy to write complex animations and user interactions. But without error stacktraces, debugging them is a nightmare. What's the plan around this? Can we expect a new version of Pico-8 with better error reporting from coroutines?



1

Not perfect but you can use that pattern:

— f is the coroutine handler
local cs=costatus(f)
if cs=="suspended" then
 assert(coresume(f))
elseif cs=="dead" then
 — dispose coroutine
end

Trick is to wrap coroutine exec with an assert.
Gives a stack trace in case of error.


Ah! I’ll give that a go. Thanks


That does stop the program when there’s an error in a coroutine. But the stack trace is confusing. It reports the location of the assert call, not the location of the error. Still... better than silently killing the coroutine.



[Please log in to post a comment]