summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_env.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-09-10 23:16:46 +0200
committerGitHub <noreply@github.com>2021-09-10 23:16:46 +0200
commit766e885a1b1c5afb7a62f11b427b6d135adeab87 (patch)
tree5fc2194936c5ad9702eba44c8636758645f98712 /src/script/cpp_api/s_env.cpp
parent7423c4c11e01edecd8db18b147bab4d2f3eeb471 (diff)
downloadminetest-766e885a1b1c5afb7a62f11b427b6d135adeab87.tar.gz
minetest-766e885a1b1c5afb7a62f11b427b6d135adeab87.tar.bz2
minetest-766e885a1b1c5afb7a62f11b427b6d135adeab87.zip
Clean up/improve some scriptapi error handling code
Diffstat (limited to 'src/script/cpp_api/s_env.cpp')
-rw-r--r--src/script/cpp_api/s_env.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/script/cpp_api/s_env.cpp b/src/script/cpp_api/s_env.cpp
index c11de3757..874c37b6e 100644
--- a/src/script/cpp_api/s_env.cpp
+++ b/src/script/cpp_api/s_env.cpp
@@ -53,13 +53,7 @@ void ScriptApiEnv::environment_Step(float dtime)
lua_getfield(L, -1, "registered_globalsteps");
// Call callbacks
lua_pushnumber(L, dtime);
- try {
- runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
- } catch (LuaError &e) {
- getServer()->setAsyncFatalError(
- std::string("environment_Step: ") + e.what() + "\n"
- + script_get_backtrace(L));
- }
+ runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
}
void ScriptApiEnv::player_event(ServerActiveObject *player, const std::string &type)
@@ -76,13 +70,7 @@ void ScriptApiEnv::player_event(ServerActiveObject *player, const std::string &t
// Call callbacks
objectrefGetOrCreate(L, player); // player
lua_pushstring(L,type.c_str()); // event type
- try {
- runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
- } catch (LuaError &e) {
- getServer()->setAsyncFatalError(
- std::string("player_event: ") + e.what() + "\n"
- + script_get_backtrace(L) );
- }
+ runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
}
void ScriptApiEnv::initializeEnvironment(ServerEnvironment *env)
@@ -257,9 +245,8 @@ void ScriptApiEnv::on_emerge_area_completion(
try {
PCALL_RES(lua_pcall(L, 4, 0, error_handler));
} catch (LuaError &e) {
- server->setAsyncFatalError(
- std::string("on_emerge_area_completion: ") + e.what() + "\n"
- + script_get_backtrace(L));
+ // Note: don't throw here, we still need to run the cleanup code below
+ server->setAsyncFatalError(e);
}
lua_pop(L, 1); // Pop error handler
@@ -300,4 +287,4 @@ void ScriptApiEnv::on_liquid_transformed(
}
runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
-} \ No newline at end of file
+}