Skip to content

Commit a5e5aa5

Browse files
t0suj4kwolekr
authored andcommittedAug 2, 2015
Prepend "Lua: " before lua exceptions
src/server.cpp src/emerge.cpp
1 parent c4287a0 commit a5e5aa5

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed
 

‎src/emerge.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@ void *EmergeThread::Thread()
494494
try { // takes about 90ms with -O1 on an e3-1230v2
495495
m_server->getScriptIface()->environment_OnGenerated(
496496
minp, maxp, mapgen->blockseed);
497-
} catch(LuaError &e) {
498-
m_server->setAsyncFatalError(e.what());
497+
} catch (LuaError &e) {
498+
m_server->setAsyncFatalError("Lua: " + std::string(e.what()));
499499
}
500500

501501
EMERGE_DBG_OUT("ended up with: " << analyze_block(block));

‎src/server.cpp

+9-20
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ServerThread : public JThread
8686
void * Thread();
8787
};
8888

89-
void * ServerThread::Thread()
89+
void *ServerThread::Thread()
9090
{
9191
log_register_thread("ServerThread");
9292

@@ -99,33 +99,22 @@ void * ServerThread::Thread()
9999

100100
porting::setThreadName("ServerThread");
101101

102-
while(!StopRequested())
103-
{
104-
try{
102+
while (!StopRequested()) {
103+
try {
105104
//TimeTaker timer("AsyncRunStep() + Receive()");
106105

107106
m_server->AsyncRunStep();
108107

109108
m_server->Receive();
110109

111-
}
112-
catch(con::NoIncomingDataException &e)
113-
{
114-
}
115-
catch(con::PeerNotFoundException &e)
116-
{
110+
} catch (con::NoIncomingDataException &e) {
111+
} catch (con::PeerNotFoundException &e) {
117112
infostream<<"Server: PeerNotFoundException"<<std::endl;
118-
}
119-
catch(ClientNotFoundException &e)
120-
{
121-
}
122-
catch(con::ConnectionBindFailed &e)
123-
{
124-
m_server->setAsyncFatalError(e.what());
125-
}
126-
catch(LuaError &e)
127-
{
113+
} catch (ClientNotFoundException &e) {
114+
} catch (con::ConnectionBindFailed &e) {
128115
m_server->setAsyncFatalError(e.what());
116+
} catch (LuaError &e) {
117+
m_server->setAsyncFatalError("Lua: " + std::string(e.what()));
129118
}
130119
}
131120

0 commit comments

Comments
 (0)