diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-03-15 16:28:59 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-03-15 16:28:59 -0400 |
commit | 31fe72dbac3d53e8da21ef116ccf99febbc5196e (patch) | |
tree | 2a040621c7ee34a67a09f50e7fe19bf9b6c34c90 /src/script/cpp_api | |
parent | f8b75555586e0e67d8320a804b9e077d29b96403 (diff) | |
download | minetest-31fe72dbac3d53e8da21ef116ccf99febbc5196e.tar.gz minetest-31fe72dbac3d53e8da21ef116ccf99febbc5196e.tar.bz2 minetest-31fe72dbac3d53e8da21ef116ccf99febbc5196e.zip |
Remove lua_State parameter from LuaError::LuaError
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r-- | src/script/cpp_api/s_base.cpp | 5 | ||||
-rw-r--r-- | src/script/cpp_api/s_inventory.cpp | 6 | ||||
-rw-r--r-- | src/script/cpp_api/s_nodemeta.cpp | 6 | ||||
-rw-r--r-- | src/script/cpp_api/s_server.cpp | 12 |
4 files changed, 15 insertions, 14 deletions
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index e28a34eee..932cc5015 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -151,13 +151,14 @@ void ScriptApiBase::realityCheck() if(top >= 30){ dstream<<"Stack is over 30:"<<std::endl; stackDump(dstream); - throw LuaError(m_luastack, "Stack is over 30 (reality check)"); + std::string traceback = script_get_backtrace(m_luastack); + throw LuaError("Stack is over 30 (reality check)\n" + traceback); } } void ScriptApiBase::scriptError() { - throw LuaError(NULL, lua_tostring(m_luastack, -1)); + throw LuaError(lua_tostring(m_luastack, -1)); } void ScriptApiBase::stackDump(std::ostream &o) diff --git a/src/script/cpp_api/s_inventory.cpp b/src/script/cpp_api/s_inventory.cpp index db3c13fe0..835c0818f 100644 --- a/src/script/cpp_api/s_inventory.cpp +++ b/src/script/cpp_api/s_inventory.cpp @@ -54,7 +54,7 @@ int ScriptApiDetached::detached_inventory_AllowMove( if(lua_pcall(L, 7, 1, errorhandler)) scriptError(); if(!lua_isnumber(L, -1)) - throw LuaError(NULL, "allow_move should return a number"); + throw LuaError("allow_move should return a number"); int ret = luaL_checkinteger(L, -1); lua_pop(L, 2); // Pop integer and error handler return ret; @@ -86,7 +86,7 @@ int ScriptApiDetached::detached_inventory_AllowPut( if(lua_pcall(L, 5, 1, errorhandler)) scriptError(); if(!lua_isnumber(L, -1)) - throw LuaError(NULL, "allow_put should return a number"); + throw LuaError("allow_put should return a number"); int ret = luaL_checkinteger(L, -1); lua_pop(L, 2); // Pop integer and error handler return ret; @@ -118,7 +118,7 @@ int ScriptApiDetached::detached_inventory_AllowTake( if(lua_pcall(L, 5, 1, errorhandler)) scriptError(); if(!lua_isnumber(L, -1)) - throw LuaError(NULL, "allow_take should return a number"); + throw LuaError("allow_take should return a number"); int ret = luaL_checkinteger(L, -1); lua_pop(L, 2); // Pop integer and error handler return ret; diff --git a/src/script/cpp_api/s_nodemeta.cpp b/src/script/cpp_api/s_nodemeta.cpp index e15abd40f..2fb683943 100644 --- a/src/script/cpp_api/s_nodemeta.cpp +++ b/src/script/cpp_api/s_nodemeta.cpp @@ -61,7 +61,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowMove(v3s16 p, scriptError(); lua_remove(L, errorhandler); // Remove error handler if(!lua_isnumber(L, -1)) - throw LuaError(NULL, "allow_metadata_inventory_move should" + throw LuaError("allow_metadata_inventory_move should" " return a number, guilty node: " + nodename); int num = luaL_checkinteger(L, -1); lua_pop(L, 1); // Pop integer @@ -100,7 +100,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowPut(v3s16 p, scriptError(); lua_remove(L, errorhandler); // Remove error handler if(!lua_isnumber(L, -1)) - throw LuaError(NULL, "allow_metadata_inventory_put should" + throw LuaError("allow_metadata_inventory_put should" " return a number, guilty node: " + nodename); int num = luaL_checkinteger(L, -1); lua_pop(L, 1); // Pop integer @@ -139,7 +139,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowTake(v3s16 p, scriptError(); lua_remove(L, errorhandler); // Remove error handler if(!lua_isnumber(L, -1)) - throw LuaError(NULL, "allow_metadata_inventory_take should" + throw LuaError("allow_metadata_inventory_take should" " return a number, guilty node: " + nodename); int num = luaL_checkinteger(L, -1); lua_pop(L, 1); // Pop integer diff --git a/src/script/cpp_api/s_server.cpp b/src/script/cpp_api/s_server.cpp index 98320b578..bffd4d3fa 100644 --- a/src/script/cpp_api/s_server.cpp +++ b/src/script/cpp_api/s_server.cpp @@ -33,7 +33,7 @@ bool ScriptApiServer::getAuth(const std::string &playername, getAuthHandler(); lua_getfield(L, -1, "get_auth"); if(lua_type(L, -1) != LUA_TFUNCTION) - throw LuaError(NULL, "Authentication handler missing get_auth"); + throw LuaError("Authentication handler missing get_auth"); lua_pushstring(L, playername.c_str()); if(lua_pcall(L, 1, 1, errorhandler)) scriptError(); @@ -48,13 +48,13 @@ bool ScriptApiServer::getAuth(const std::string &playername, std::string password; bool found = getstringfield(L, -1, "password", password); if(!found) - throw LuaError(NULL, "Authentication handler didn't return password"); + throw LuaError("Authentication handler didn't return password"); if(dst_password) *dst_password = password; lua_getfield(L, -1, "privileges"); if(!lua_istable(L, -1)) - throw LuaError(NULL, "Authentication handler didn't return privilege table"); + throw LuaError("Authentication handler didn't return privilege table"); if(dst_privs) readPrivileges(-1, *dst_privs); lua_pop(L, 1); @@ -74,7 +74,7 @@ void ScriptApiServer::getAuthHandler() } lua_remove(L, -2); // Remove minetest if(lua_type(L, -1) != LUA_TTABLE) - throw LuaError(NULL, "Authentication handler table not valid"); + throw LuaError("Authentication handler table not valid"); } void ScriptApiServer::readPrivileges(int index, std::set<std::string> &result) @@ -108,7 +108,7 @@ void ScriptApiServer::createAuth(const std::string &playername, lua_getfield(L, -1, "create_auth"); lua_remove(L, -2); // Remove auth handler if(lua_type(L, -1) != LUA_TFUNCTION) - throw LuaError(NULL, "Authentication handler missing create_auth"); + throw LuaError("Authentication handler missing create_auth"); lua_pushstring(L, playername.c_str()); lua_pushstring(L, password.c_str()); if(lua_pcall(L, 2, 0, errorhandler)) @@ -128,7 +128,7 @@ bool ScriptApiServer::setPassword(const std::string &playername, lua_getfield(L, -1, "set_password"); lua_remove(L, -2); // Remove auth handler if(lua_type(L, -1) != LUA_TFUNCTION) - throw LuaError(NULL, "Authentication handler missing set_password"); + throw LuaError("Authentication handler missing set_password"); lua_pushstring(L, playername.c_str()); lua_pushstring(L, password.c_str()); if(lua_pcall(L, 2, 1, errorhandler)) |