From f05e8649eddd2180e39ebe9482fee29bf7652c97 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 26 Oct 2018 19:29:08 +0100 Subject: util.xpcall, util.compat: Add non-hacky multi-argument xpcall() for Lua 5.1 --- util/xpcall.lua | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 util/xpcall.lua (limited to 'util/xpcall.lua') diff --git a/util/xpcall.lua b/util/xpcall.lua new file mode 100644 index 00000000..d2fc5011 --- /dev/null +++ b/util/xpcall.lua @@ -0,0 +1,9 @@ +local xpcall = xpcall; + +if select(2, xpcall(function (x) return x end, function () end, "test")) ~= "test" then + xpcall = require"util.compat".xpcall; +end + +return { + xpcall = xpcall; +}; -- cgit v1.2.3