Server::step throw is never catched in minetestserver
authorLoic Blot <loic.blot@unix-experience.fr>
Tue, 17 Mar 2015 08:13:12 +0000 (09:13 +0100)
committerLoic Blot <loic.blot@unix-experience.fr>
Tue, 17 Mar 2015 14:26:20 +0000 (15:26 +0100)
Replace it with an errorstream + assert for server

This throw can be trigger by LuaError exception or ConnectionBindFailed exception in the following functions:
* EmergeThread::Thread()
* ScriptApiEnv::environment_Step()
* ScriptApiEnv::player_event()
* ServerThread::Thread()

src/server.cpp

index 18968cdf98c7d700eb86e33e8bfb4989516361dd..235e802bbfab826cb2001c2af5077c68257a336b 100644 (file)
@@ -481,8 +481,16 @@ void Server::step(float dtime)
        }
        // Throw if fatal error occurred in thread
        std::string async_err = m_async_fatal_error.get();
-       if(async_err != ""){
-               throw ServerError(async_err);
+       if(async_err != "") {
+               if (m_simple_singleplayer_mode) {
+                       throw ServerError(async_err);
+               }
+               else {
+                       errorstream << "UNRECOVERABLE error occurred. Stopping server. "
+                                       << "Please fix the following error:" << std::endl
+                                       << async_err << std::endl;
+                       FATAL_ERROR(async_err.c_str());
+               }
        }
 }