Error Values Eagerly Formatted
A Lua error can contain any Lua value, bubbling up the stack to the nearest native function (or pcall). The following Lua code for instance uses an error to call a function and actually prints `"Hello, World".
local function thing()
print("Hello, World")
end
local function fallible()
error(thing)
end
local err, result = pcall(fallible)
result()
This can be useful in situations where an error is intended to carry data or otherwise have some meaning to the code receiving it. It seems like, however, mlua eagerly formats all RuntimeErrors upon receiving them, erasing any actual values carried with them. Looking at the source code I see no immediate reason for this. Is this simply a limitation of mlua?
This appears to be the offending line, I do apologize if I've missed some reason this is nessecary. https://github.com/mlua-rs/mlua/blob/85b280a9d68796ad9c438cc26120839e4665e4fe/src/util/error.rs#L123