summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_async.cpp
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-10-29 14:48:10 -0400
committerShadowNinja <shadowninja@minetest.net>2015-10-31 13:28:58 -0400
commit9269a0ecc7267822bc5ac5af95ad4977bdc94fec (patch)
tree1cf8639cc0a6b367670ac673780f321f85b467be /src/script/cpp_api/s_async.cpp
parentb872df6ef6a15ae4624b35ea7b8960bc24da1128 (diff)
downloadminetest-9269a0ecc7267822bc5ac5af95ad4977bdc94fec.tar.gz
minetest-9269a0ecc7267822bc5ac5af95ad4977bdc94fec.tar.bz2
minetest-9269a0ecc7267822bc5ac5af95ad4977bdc94fec.zip
Fix server crashing on Lua errors
Previously, the server called FATAL_ERROR when a Lua error occured. This caused a (mostly useless) core dump. The server now simply throws an exception, which is caught and printed before exiting with a non-zero return value. This also fixes a number of instances where errors were logged multiple times.
Diffstat (limited to 'src/script/cpp_api/s_async.cpp')
-rw-r--r--src/script/cpp_api/s_async.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/script/cpp_api/s_async.cpp b/src/script/cpp_api/s_async.cpp
index 171632633..9bf3fcf49 100644
--- a/src/script/cpp_api/s_async.cpp
+++ b/src/script/cpp_api/s_async.cpp
@@ -243,8 +243,12 @@ void* AsyncWorkerThread::run()
lua_State *L = getStack();
std::string script = getServer()->getBuiltinLuaPath() + DIR_DELIM + "init.lua";
- if (!loadScript(script)) {
- FATAL_ERROR("execution of async base environment failed!");
+ try {
+ loadScript(script);
+ } catch (const ModError &e) {
+ errorstream << "Execution of async base environment failed: "
+ << e.what() << std::endl;
+ FATAL_ERROR("Execution of async base environment failed");
}
int error_handler = PUSH_ERROR_HANDLER(L);