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)


Not perfect but you can use that pattern:

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

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)
:: dredds

Ah! I’ll give that a go. Thanks

P#65594 2019-07-05 10:10
:: dredds

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 2020-10-25 17:26 | 0.019s | 2097k | Q:15