Normally, Lua would support this, but it seems ROBLOX removed support for it. Having coroutine support for debug.traceback is useful for debugging, especially in ‘multi-threaded’ situations. For example:
local c = coroutine.create(function()
error("test")
end)
local succ, err = coroutine.resume(c)
print(succ, err)
print(debug.traceback(c))
Unfortunately, in ROBLOX, this does not work correctly and does not produce the correct stack trace.
Compare what the standalone Lua interpreter gives to what ROBLOX gives:
> print(succ, err)
false stdin:2: test
> print(debug.traceback(c))
stack traceback:
[C]: in function 'error'
stdin:2: in function <stdin:1>
>
false <<code>>:2: test
Script '<<code>>', Line 7
Stack End
As you can tell, the stack traceback is occuring from where debug.traceback() was called; not where the coroutine errored which is where it would be useful.
The only way to achieve a similar effect right now is to use xpcall, which unfortunately does not support yielding and so makes it a lot harder to debug.