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?

P#65592 2019-07-05 09:33 ( Edited 2019-07-05 09:34)

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.

P#65593 2019-07-05 10:04 ( Edited 2019-07-05 10:06)

Ah! I’ll give that a go. Thanks

P#65594 2019-07-05 10:10

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.

P#65614 2019-07-05 18:05

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 17:06:23 | 0.013s | Q:13