ziglua
ziglua copied to clipboard
Update wrap functions to handle error unions
It would sometimes be useful to use try in a wrapped zig function and have that propagate as a Lua error. This should be pretty easy to do with comptime
My implementation of autoPushFunction automatically does this.
if (@typeInfo(info.Fn.return_type.?) == .ErrorUnion) {
const result = @call(.auto, function, parameters) catch |err| {
lua.raiseErrorStr(@errorName(err), .{});
};
lua.pushAny(result);
} else {
const result = @call(.auto, function, parameters);
lua.pushAny(result);
}