After you call coroutine.yield(), errors just don’t show in output anymore @woot3
Repro:
local c = coroutine.running()
delay(1, function()
coroutine.resume(c)
end)
coroutine.yield()
print("done") --This prints
print(2+e) --The error for this doesn't show
“Note that resume runs in protected mode. Therefore, if there is any error inside a coroutine, Lua will not show the error message, but instead will return it to the resume call.” https://www.lua.org/pil/9.1.html
I don’t believe roblox changed up their implementation for resume from the out-of-box version of Lua.
Edit: adding assert should be an easy way to get your desired behavior. assert(coroutine.resume(c));
Looked around for a bit to find this was already a reported issue. Just encountered it myself and had me stumped for a few minutes as to why my code was just stopping at a seemingly normal statement. Turns out an error was being thrown and it was swallowed up because much earlier in the code I had used coroutine.yield() to wait for a bunch of coroutines to finish.
I think a good solution would be to have threads retain their normal error propagation behavior if that’s how they were first created.
I see. I was aware resume was eating up the errors but I considered the behavior of doing so even on threads that weren’t started by the user a weird implementation detail. I do like the idea of a separate function for this kind of behavior, but I would also prefer Roblox change it to still propagate errors from those kind of threads.
It doesn’t seem obvious to the average user that errors would behave like this, in my opinion.