aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-03-15 16:01:06 -0400
committerShadowNinja <shadowninja@minetest.net>2014-03-15 16:01:06 -0400
commitf8b75555586e0e67d8320a804b9e077d29b96403 (patch)
treef992793df77298fab89185848d81ebe5f05da3a6 /src/script
parent23be6450a115954b281c045aefacbefba6837b6f (diff)
downloadminetest-f8b75555586e0e67d8320a804b9e077d29b96403.tar.gz
minetest-f8b75555586e0e67d8320a804b9e077d29b96403.tar.bz2
minetest-f8b75555586e0e67d8320a804b9e077d29b96403.zip
Revert "Make sure we get a stacktrace for as many lua errors as possible"
This reverts commit 362ef5f6ced862daa4733034810d0b07e2ad5d89. Stack tracebacks couldn't be generated in LuaError::LuaError anyway and this caused a second, empty traceback in most cases. In cases where there wasn't annother traceback the stack had already unwound and the traceback was empty.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/common/c_content.cpp4
-rw-r--r--src/script/common/c_internal.cpp2
-rw-r--r--src/script/cpp_api/s_inventory.cpp6
-rw-r--r--src/script/cpp_api/s_nodemeta.cpp6
-rw-r--r--src/script/cpp_api/s_server.cpp12
-rw-r--r--src/script/lua_api/l_craft.cpp28
6 files changed, 29 insertions, 29 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 4730ca14d..899e1c536 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -654,7 +654,7 @@ ItemStack read_item(lua_State* L, int index,Server* srv)
}
else
{
- throw LuaError(L, "Expecting itemstack, itemstring, table or nil");
+ throw LuaError(NULL, "Expecting itemstack, itemstring, table or nil");
}
}
@@ -941,7 +941,7 @@ std::vector<ItemStack> read_items(lua_State *L, int index, Server *srv)
while (lua_next(L, index)) {
s32 key = luaL_checkinteger(L, -2);
if (key < 1) {
- throw LuaError(L, "Invalid inventory list index");
+ throw LuaError(NULL, "Invalid inventory list index");
}
if (items.size() < (u32) key) {
items.resize(key);
diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp
index b7dfb178c..90846676f 100644
--- a/src/script/common/c_internal.cpp
+++ b/src/script/common/c_internal.cpp
@@ -71,7 +71,7 @@ void script_error(lua_State *L)
{
const char *s = lua_tostring(L, -1);
std::string str(s ? s : "");
- throw LuaError(L, str);
+ throw LuaError(NULL, str);
}
// Push the list of callbacks (a lua table).
diff --git a/src/script/cpp_api/s_inventory.cpp b/src/script/cpp_api/s_inventory.cpp
index c4912163a..db3c13fe0 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(L, "allow_move should return a number");
+ throw LuaError(NULL, "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(L, "allow_put should return a number");
+ throw LuaError(NULL, "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(L, "allow_take should return a number");
+ throw LuaError(NULL, "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 9513238c9..e15abd40f 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(L, "allow_metadata_inventory_move should"
+ throw LuaError(NULL, "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(L, "allow_metadata_inventory_put should"
+ throw LuaError(NULL, "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(L, "allow_metadata_inventory_take should"
+ throw LuaError(NULL, "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 4baf90636..98320b578 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(L, "Authentication handler missing get_auth");
+ throw LuaError(NULL, "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(L, "Authentication handler didn't return password");
+ throw LuaError(NULL, "Authentication handler didn't return password");
if(dst_password)
*dst_password = password;
lua_getfield(L, -1, "privileges");
if(!lua_istable(L, -1))
- throw LuaError(L, "Authentication handler didn't return privilege table");
+ throw LuaError(NULL, "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(L, "Authentication handler table not valid");
+ throw LuaError(NULL, "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(L, "Authentication handler missing create_auth");
+ throw LuaError(NULL, "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(L, "Authentication handler missing set_password");
+ throw LuaError(NULL, "Authentication handler missing set_password");
lua_pushstring(L, playername.c_str());
lua_pushstring(L, password.c_str());
if(lua_pcall(L, 2, 1, errorhandler))
diff --git a/src/script/lua_api/l_craft.cpp b/src/script/lua_api/l_craft.cpp
index 240aa045c..aaca84c56 100644
--- a/src/script/lua_api/l_craft.cpp
+++ b/src/script/lua_api/l_craft.cpp
@@ -150,16 +150,16 @@ int ModApiCraft::l_register_craft(lua_State *L)
if(type == "shaped"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
- throw LuaError(L, "Crafting definition is missing an output");
+ throw LuaError(NULL, "Crafting definition is missing an output");
int width = 0;
std::vector<std::string> recipe;
lua_getfield(L, table, "recipe");
if(lua_isnil(L, -1))
- throw LuaError(L, "Crafting definition is missing a recipe"
+ throw LuaError(NULL, "Crafting definition is missing a recipe"
" (output=\"" + output + "\")");
if(!readCraftRecipeShaped(L, -1, width, recipe))
- throw LuaError(L, "Invalid crafting recipe"
+ throw LuaError(NULL, "Invalid crafting recipe"
" (output=\"" + output + "\")");
CraftReplacements replacements;
@@ -167,7 +167,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
- throw LuaError(L, "Invalid replacements"
+ throw LuaError(NULL, "Invalid replacements"
" (output=\"" + output + "\")");
}
@@ -181,17 +181,17 @@ int ModApiCraft::l_register_craft(lua_State *L)
else if(type == "shapeless"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
- throw LuaError(L, "Crafting definition (shapeless)"
+ throw LuaError(NULL, "Crafting definition (shapeless)"
" is missing an output");
std::vector<std::string> recipe;
lua_getfield(L, table, "recipe");
if(lua_isnil(L, -1))
- throw LuaError(L, "Crafting definition (shapeless)"
+ throw LuaError(NULL, "Crafting definition (shapeless)"
" is missing a recipe"
" (output=\"" + output + "\")");
if(!readCraftRecipeShapeless(L, -1, recipe))
- throw LuaError(L, "Invalid crafting recipe"
+ throw LuaError(NULL, "Invalid crafting recipe"
" (output=\"" + output + "\")");
CraftReplacements replacements;
@@ -199,7 +199,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
- throw LuaError(L, "Invalid replacements"
+ throw LuaError(NULL, "Invalid replacements"
" (output=\"" + output + "\")");
}
@@ -224,12 +224,12 @@ int ModApiCraft::l_register_craft(lua_State *L)
else if(type == "cooking"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
- throw LuaError(L, "Crafting definition (cooking)"
+ throw LuaError(NULL, "Crafting definition (cooking)"
" is missing an output");
std::string recipe = getstringfield_default(L, table, "recipe", "");
if(recipe == "")
- throw LuaError(L, "Crafting definition (cooking)"
+ throw LuaError(NULL, "Crafting definition (cooking)"
" is missing a recipe"
" (output=\"" + output + "\")");
@@ -240,7 +240,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
- throw LuaError(L, "Invalid replacements"
+ throw LuaError(NULL, "Invalid replacements"
" (cooking output=\"" + output + "\")");
}
@@ -254,7 +254,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
else if(type == "fuel"){
std::string recipe = getstringfield_default(L, table, "recipe", "");
if(recipe == "")
- throw LuaError(L, "Crafting definition (fuel)"
+ throw LuaError(NULL, "Crafting definition (fuel)"
" is missing a recipe");
float burntime = getfloatfield_default(L, table, "burntime", 1.0);
@@ -264,7 +264,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
- throw LuaError(L, "Invalid replacements"
+ throw LuaError(NULL, "Invalid replacements"
" (fuel recipe=\"" + recipe + "\")");
}
@@ -274,7 +274,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
}
else
{
- throw LuaError(L, "Unknown crafting definition type: \"" + type + "\"");
+ throw LuaError(NULL, "Unknown crafting definition type: \"" + type + "\"");
}
lua_pop(L, 1);