From 9269a0ecc7267822bc5ac5af95ad4977bdc94fec Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Thu, 29 Oct 2015 14:48:10 -0400 Subject: 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. --- src/script/cpp_api/s_async.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/script/cpp_api/s_async.cpp') 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); -- cgit v1.2.3