[Server] Add custom terminate handler with stacktrace

new-script-api
Koncord 7 years ago
parent a3d5fbbdcd
commit dad0b38f25

@ -139,8 +139,25 @@ boost::program_options::variables_map launchOptions(int argc, char *argv[], File
return variables;
}
#include "stacktrace.hpp"
int main(int argc, char *argv[])
{
set_terminate([]() {
try
{
rethrow_exception(current_exception());
}
catch (const exception &e)
{
LOG_MESSAGE_SIMPLE(Log::LOG_FATAL, " Woops, something wrong! Exception:\n\t%s", e.what());
}
stacktrace();
abort();
});
Settings::Manager mgr;
Files::ConfigurationManager cfgMgr;
@ -210,9 +227,6 @@ int main(int argc, char *argv[])
RakNet::SocketDescriptor sd((unsigned short) port, addr.c_str());
//try
{
switch (peer->Startup((unsigned) players, &sd, 1))
{
case RakNet::RAKNET_STARTED:
@ -252,7 +266,8 @@ int main(int argc, char *argv[])
for (int i = 0;; ++i)
list.push_back(mgr.getString("Plugin" + to_string(i), "Plugins"));
}
catch (...) {} // Manager::getString throws runtime_error exception if setting is not exist
catch (...)
{} // Manager::getString throws runtime_error exception if setting is not exist
networking.getState().loadMods(plugin_home, &list);
}
@ -282,12 +297,6 @@ int main(int argc, char *argv[])
code = networking.mainLoop();
networking.getMasterClient()->Stop();
}
/*catch (std::exception &e)
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
throw; //fall through
}*/
RakNet::RakPeerInterface::DestroyInstance(peer);

Loading…
Cancel
Save