lune-org/lune

Error handling

Closed this issue ยท 4 comments

Hello ๐Ÿ‘‹

I noticed that errors are getting automatically wrapped up into some opaque type. I can stringify the error and see what was originally thrown, but I can't get back the thrown value. For example, it would be great if I could do something like this:

local function throwError()
    error({ message = "error" })
end

local success, err = pcall(throwError)

print("success", success) --> false

print("err", type(err)) --> userdata

print("err.message", err.message) --> throws: attempt to index userdata with 'message'

(also I tested it using xpcall and the error passed to the second callback has the same issue)

This is due to how the luau library we use handles errors, I've made an issue to track this over on their repo: mlua-rs/mlua#263

Fixed in the new scheduler on the soon-to-be-merged scheduler-rewrite branch, also added a test in 5ccc481 to make sure we don't regress on this

Awesome! This is great as it closes a big gap between the Roblox environment and Lune!