From 4a0aa6eecf10432453c22031c247cf24819f1040 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 12 May 2017 14:52:14 +1000 Subject: Add facility for a user provided (state-global) native error handler --- src/lapi.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/lapi.js') diff --git a/src/lapi.js b/src/lapi.js index f56fc81..c0e619b 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -36,6 +36,12 @@ const lua_atpanic = function(L, panicf) { return old; }; +const lua_atnativeerror = function(L, errorf) { + let old = L.l_G.atnativeerror; + L.l_G.atnativeerror = errorf; + return old; +}; + // Return value for idx on stack const index2addr = function(L, idx) { let ci = L.ci; @@ -1104,6 +1110,7 @@ module.exports.index2addr_ = index2addr_; module.exports.lua_absindex = lua_absindex; module.exports.lua_arith = lua_arith; module.exports.lua_atpanic = lua_atpanic; +module.exports.lua_atnativeerror = lua_atnativeerror; module.exports.lua_call = lua_call; module.exports.lua_callk = lua_callk; module.exports.lua_checkstack = lua_checkstack; -- cgit v1.2.3-54-g00ecf