aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/cpp_api/s_item.cpp')
-rw-r--r--src/script/cpp_api/s_item.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/script/cpp_api/s_item.cpp b/src/script/cpp_api/s_item.cpp
index 24955cefc..48dce14f3 100644
--- a/src/script/cpp_api/s_item.cpp
+++ b/src/script/cpp_api/s_item.cpp
@@ -29,6 +29,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "inventory.h"
#include "inventorymanager.h"
+#define WRAP_LUAERROR(e, detail) \
+ LuaError(std::string(__FUNCTION__) + ": " + (e).what() + ". " detail)
+
bool ScriptApiItem::item_OnDrop(ItemStack &item,
ServerActiveObject *dropper, v3f pos)
{
@@ -49,7 +52,7 @@ bool ScriptApiItem::item_OnDrop(ItemStack &item,
try {
item = read_item(L, -1, getServer()->idef());
} catch (LuaError &e) {
- throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ throw WRAP_LUAERROR(e, "item=" + item.name);
}
}
lua_pop(L, 2); // Pop item and error handler
@@ -81,7 +84,7 @@ bool ScriptApiItem::item_OnPlace(ItemStack &item,
try {
item = read_item(L, -1, getServer()->idef());
} catch (LuaError &e) {
- throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ throw WRAP_LUAERROR(e, "item=" + item.name);
}
}
lua_pop(L, 2); // Pop item and error handler
@@ -108,7 +111,7 @@ bool ScriptApiItem::item_OnUse(ItemStack &item,
try {
item = read_item(L, -1, getServer()->idef());
} catch (LuaError &e) {
- throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ throw WRAP_LUAERROR(e, "item=" + item.name);
}
}
lua_pop(L, 2); // Pop item and error handler
@@ -133,7 +136,7 @@ bool ScriptApiItem::item_OnSecondaryUse(ItemStack &item,
try {
item = read_item(L, -1, getServer()->idef());
} catch (LuaError &e) {
- throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ throw WRAP_LUAERROR(e, "item=" + item.name);
}
}
lua_pop(L, 2); // Pop item and error handler
@@ -165,7 +168,7 @@ bool ScriptApiItem::item_OnCraft(ItemStack &item, ServerActiveObject *user,
try {
item = read_item(L, -1, getServer()->idef());
} catch (LuaError &e) {
- throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ throw WRAP_LUAERROR(e, "item=" + item.name);
}
}
lua_pop(L, 2); // Pop item and error handler
@@ -197,7 +200,7 @@ bool ScriptApiItem::item_CraftPredict(ItemStack &item, ServerActiveObject *user,
try {
item = read_item(L, -1, getServer()->idef());
} catch (LuaError &e) {
- throw LuaError(std::string(e.what()) + ". item=" + item.name);
+ throw WRAP_LUAERROR(e, "item=" + item.name);
}
}
lua_pop(L, 2); // Pop item and error handler