aboutsummaryrefslogtreecommitdiffstats
path: root/util/xpcall.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-10-26 19:29:08 +0100
committerMatthew Wild <mwild1@gmail.com>2018-10-26 19:29:08 +0100
commit1454ac8208cfb734d1ae90dd89c442b6be9f9598 (patch)
tree20620497ffafc592a84e2c9069ee6daa246a8f42 /util/xpcall.lua
parent9fdfa590d2d910b0104e4e37d4c7403cbc4d4151 (diff)
downloadprosody-1454ac8208cfb734d1ae90dd89c442b6be9f9598.tar.gz
prosody-1454ac8208cfb734d1ae90dd89c442b6be9f9598.zip
util.xpcall, util.compat: Add non-hacky multi-argument xpcall() for Lua 5.1
Diffstat (limited to 'util/xpcall.lua')
-rw-r--r--util/xpcall.lua9
1 files changed, 9 insertions, 0 deletions
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;
+};