aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-04 12:32:39 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-04 12:32:55 +1000
commite78c26fbbd69e09f5271371eccc99f967de7540a (patch)
tree7f99b9d5572e883c84c50c4f14cd6ea8dec918b3
parent097d9a2834b7dbceb44b24f3ff73d798b98900f7 (diff)
downloadfengari-e78c26fbbd69e09f5271371eccc99f967de7540a.tar.gz
fengari-e78c26fbbd69e09f5271371eccc99f967de7540a.tar.bz2
fengari-e78c26fbbd69e09f5271371eccc99f967de7540a.zip
src/ldo.js: Throw JS errors as runtime errors
-rw-r--r--src/ldo.js10
1 files 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) {}
}
}