From e78c26fbbd69e09f5271371eccc99f967de7540a Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 4 May 2017 12:32:39 +1000 Subject: src/ldo.js: Throw JS errors as runtime errors --- src/ldo.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ldo.js b/src/ldo.js index c762798..004c659 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -297,10 +297,14 @@ const luaD_rawrunprotected = function(L, f, ud) { try { f(L, ud); } catch (e) { - if (lj.status === 0) { + if (lj.status === TS.LUA_OK) { + /* error was not thrown via luaD_throw, i.e. it is a JS error */ lj.status = -1; - /* error was not thrown via luaD_throw; push error object as light user data */ - lapi.lua_pushlightuserdata(L, e); + /* run error handler (if possible) with error object as light userdata */ + try { + lapi.lua_pushlightuserdata(L, e); + ldebug.luaG_errormsg(L); + } catch (e) {} } } -- cgit v1.2.3-70-g09d2