summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings_BlockArea.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-11 17:39:43 +0100
committerGitHub <noreply@github.com>2021-01-11 17:39:43 +0100
commiteeb63b8901a9c049f1bb594abb9ce9b4a9c47620 (patch)
treeb07daae788f918b83eeb0bdbd51e49292f1c8d88 /src/Bindings/ManualBindings_BlockArea.cpp
parentFixed switch-ups regarding some slab and stair recipes (#5099) (diff)
downloadcuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.gz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.bz2
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.lz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.xz
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.zst
cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.zip
Diffstat (limited to 'src/Bindings/ManualBindings_BlockArea.cpp')
-rw-r--r--src/Bindings/ManualBindings_BlockArea.cpp50
1 files changed, 42 insertions, 8 deletions
diff --git a/src/Bindings/ManualBindings_BlockArea.cpp b/src/Bindings/ManualBindings_BlockArea.cpp
index 5af150599..5f281fadc 100644
--- a/src/Bindings/ManualBindings_BlockArea.cpp
+++ b/src/Bindings/ManualBindings_BlockArea.cpp
@@ -435,7 +435,17 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * a_LuaState)
return L.ApiParamError("Invalid 'self', must not be nil");
}
- L.Push(cSchematicFileSerializer::LoadFromSchematicFile(*self, fileName));
+ try
+ {
+ cSchematicFileSerializer::LoadFromSchematicFile(*self, fileName);
+ L.Push(true);
+ }
+ catch (const std::exception & Oops)
+ {
+ LOGWARNING(Oops.what());
+ L.LogStackTrace();
+ L.Push(false);
+ }
return 1;
}
@@ -457,7 +467,7 @@ static int tolua_cBlockArea_LoadFromSchematicString(lua_State * a_LuaState)
return 0;
}
cBlockArea * self;
- AString data;
+ ContiguousByteBuffer data;
if (!L.GetStackValues(1, self, data))
{
return L.ApiParamError("Cannot read the parameters");
@@ -467,7 +477,17 @@ static int tolua_cBlockArea_LoadFromSchematicString(lua_State * a_LuaState)
return L.ApiParamError("Invalid 'self', must not be nil");
}
- L.Push(cSchematicFileSerializer::LoadFromSchematicString(*self, data));
+ try
+ {
+ cSchematicFileSerializer::LoadFromSchematicString(*self, data);
+ L.Push(true);
+ }
+ catch (const std::exception & Oops)
+ {
+ LOGWARNING(Oops.what());
+ L.LogStackTrace();
+ L.Push(false);
+ }
return 1;
}
@@ -625,7 +645,17 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * a_LuaState)
return L.ApiParamError("Invalid 'self', must not be nil");
}
- L.Push(cSchematicFileSerializer::SaveToSchematicFile(*self, fileName));
+ try
+ {
+ cSchematicFileSerializer::SaveToSchematicFile(*self, fileName);
+ L.Push(true);
+ }
+ catch (const std::exception & Oops)
+ {
+ LOGWARNING(Oops.what());
+ L.LogStackTrace();
+ L.Push(false);
+ }
return 1;
}
@@ -655,13 +685,17 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * a_LuaState)
return L.ApiParamError("Invalid 'self', must not be nil");
}
- AString data;
- if (cSchematicFileSerializer::SaveToSchematicString(*self, data))
+ try
{
- L.Push(data);
+ L.Push(cSchematicFileSerializer::SaveToSchematicString(*self).GetView());
return 1;
}
- return 0;
+ catch (const std::exception & Oops)
+ {
+ LOGWARNING(Oops.what());
+ L.LogStackTrace();
+ return 0;
+ }
}