Open GasimGasimzada opened 8 months ago
Hmm. I don't think sol has an error mechanism like that. And calling lua's error functions would not clean up any objects that sol has created I think as it would do longjmp.
What is the usecase? Why not use exception?
We have the same issue as our codebase has exceptions disabled.
One convoluted workaround is to return a string with the error message and call error
on the Lua side if the result is a string.
Ideally, sol would be integrated with std::expected
(or tl::expected
) so that the lamba could just return an expected<T, std::string>
and sol would handle the unwrapping and calling Lua's error
.
Assuming I have a function like this:
How can I fail this function?