summaryrefslogtreecommitdiff
path: root/src/lbaselib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-21 12:53:41 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-21 13:03:58 +0100
commit82ef443de9a3ba53b4a5b9abd161ddc164776a59 (patch)
treeb28dea891d19c1cb472551d4f2b24844e94b44e9 /src/lbaselib.js
parente111f5cb7a21455df2c62eb65cd7b38aac0d834c (diff)
downloadfengari-82ef443de9a3ba53b4a5b9abd161ddc164776a59.tar.gz
fengari-82ef443de9a3ba53b4a5b9abd161ddc164776a59.tar.bz2
fengari-82ef443de9a3ba53b4a5b9abd161ddc164776a59.zip
Use correct luaG errors instead of throwing Errors
Diffstat (limited to 'src/lbaselib.js')
-rw-r--r--src/lbaselib.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index 16c63bf..205d57a 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -19,7 +19,7 @@ const luaB_print = function(L) {
lapi.lua_call(L, 1, 1);
let s = lapi.lua_tolstring(L, -1);
if (s === null)
- throw new Error("'tostring' must return a string to 'print");
+ return lauxlib.luaL_error(L, "'tostring' must return a string to 'print'");
if (i > 1) s = `\t${s}`;
str = `${str}${s}`;
lapi.lua_pop(L, 1);
@@ -51,7 +51,7 @@ const luaB_setmetatable = function(L) {
lauxlib.luaL_checktype(L, 1, CT.LUA_TTABLE);
lauxlib.luaL_argcheck(L, t === CT.LUA_TNIL || t === CT.LUA_TTABLE, 2, "nil or table expected");
if (lauxlib.luaL_getmetafield(L, 1, "__metatable") !== CT.LUA_TNIL)
- throw new Error("cannot change a protected metatable");
+ return lauxlib.luaL_error(L, "cannot change a protected metatable");
lapi.lua_settop(L, 2);
lapi.lua_setmetatable(L, 1);
return 1;