Coroutine suppresses errors of functions in an unwanted manner

image

Above, a for loop will take a table of module’s data. Each entry, denoted as “v” in the for loop, is structured like so: {name=“something here”,data={boot=function()}}.

The problem with this is, I’m trying to print out any errors from the boot() function, but the coroutine seems to suppress those errors.

I need help finding out how I can still call functions asynchronously, while being able to detect errors they throw—Preferably without use of spawn()

You could use coroutine.warp() to call the function:

local s,e = pcall(function()
    coroutine.wrap(v.data.boot)()
end)
1 Like

coroutine.resume already returns the success and the error.

local s,e = coroutine.resume(coroutine.create(v.data.boot))
3 Likes