Commit 8aeaf1de authored by Pavel Vainerman's avatar Pavel Vainerman

Прошёлся по вылавливаниям исключений. Добавил ловушку для std::exception

parent d9586f64
......@@ -113,9 +113,9 @@ int main( int argc, char **argv )
{
cerr << "(mbtcpserver): " << ex << endl;
}
catch( ost::SockException& e )
catch( std::exception& e )
{
cerr << e.getString() << ": " << e.getSystemErrorString() << endl;
cerr << "(mbtcpserver): " << e.what() << endl;
}
catch(...)
{
......
......@@ -423,9 +423,9 @@ int main( int argc, char **argv )
{
cerr << "(mbtester): " << ex << endl;
}
catch( ost::SockException& e )
catch( std::exception& e )
{
cerr << e.getString() << ": " << e.getSystemErrorString() << endl;
cerr << "(mbtester): " << e.what() << endl;
}
catch(...)
{
......
......@@ -86,9 +86,9 @@ int main(int argc, const char **argv)
{
dlog[Debug::CRIT] << "(mbslave): " << ex << endl;
}
catch( ost::SockException& e )
catch( std::exception& e )
{
dlog[Debug::CRIT] << e.getString() << ": " << e.getSystemErrorString() << endl;
dlog[Debug::CRIT] << "(mbslave): " << e.what() << endl;
}
catch(...)
{
......
......@@ -42,14 +42,18 @@ int main(int argc, const char **argv)
// pause(); // пауза, чтобы дочерние потоки успели завершить работу
return 0;
}
catch(SystemError& err)
catch( SystemError& err )
{
unideb[Debug::CRIT] << "(smemory): " << err << endl;
}
catch(Exception& ex)
catch( Exception& ex )
{
unideb[Debug::CRIT] << "(smemory): " << ex << endl;
}
catch( std::exception& e )
{
unideb[Debug::CRIT] << "(smemory): " << e.what() << endl;
}
catch(...)
{
unideb[Debug::CRIT] << "(smemory): catch(...)" << endl;
......
......@@ -259,14 +259,14 @@ void UNetReceiver::receive()
if( recv() )
ptRecvTimeout.reset();
}
catch( ost::SockException& e )
{
dlog[Debug::WARN] << myname << "(receive): " << e.getString() << endl;
}
catch( UniSetTypes::Exception& ex)
{
dlog[Debug::WARN] << myname << "(receive): " << ex << std::endl;
}
catch( std::exception& e )
{
dlog[Debug::WARN] << myname << "(receive): " << e.what()<< std::endl;
}
catch(...)
{
dlog[Debug::WARN] << myname << "(receive): catch ..." << std::endl;
......
......@@ -161,6 +161,10 @@ void UNetSender::send()
{
dlog[Debug::WARN] << myname << "(send): " << ex << std::endl;
}
catch( std::exception& e )
{
dlog[Debug::WARN] << myname << "(send): " << e.what() << std::endl;
}
catch(...)
{
dlog[Debug::WARN] << myname << "(send): catch ..." << std::endl;
......
......@@ -289,10 +289,9 @@ int main(int argc, char* argv[])
break;
}
}
catch( ost::SockException& e )
catch( std::exception& e )
{
cerr << "(main): " << e.getString() << " (" << addr << ")" << endl;
return 1;
cerr << "(main): " << e.what() << endl;
}
catch( ... )
{
......
......@@ -104,8 +104,8 @@ mbErrCode ModbusTCPServer::receive( ModbusRTU::ModbusAddr addr, timeout_t timeou
send(buf);
printProcessingTime();
}
else if( aftersend_msec >= 0 )
msleep(aftersend_msec);
else if( aftersend_msec >= 0 )
msleep(aftersend_msec);
tcp.disconnect();
return res;
......@@ -135,9 +135,9 @@ mbErrCode ModbusTCPServer::receive( ModbusRTU::ModbusAddr addr, timeout_t timeou
tcp.disconnect();
}
}
catch( ost::SockException& e )
catch( ost::Exception& e )
{
cout << e.getString() << ": " << e.getSystemErrorString() << endl;
cout << "(ModbusTCPServer): " << e.what() << endl;
return erInternalErrorCode;
}
......@@ -225,16 +225,16 @@ mbErrCode ModbusTCPServer::pre_send_request( ModbusMessage& request )
return erNoError;
}
// -------------------------------------------------------------------------
void ModbusTCPServer::cleanInputStream()
{
unsigned char buf[100];
int ret=0;
do
{
ret = getNextData(buf,sizeof(buf));
}
while( ret > 0);
}
void ModbusTCPServer::cleanInputStream()
{
unsigned char buf[100];
int ret=0;
do
{
ret = getNextData(buf,sizeof(buf));
}
while( ret > 0);
}
// -------------------------------------------------------------------------
void ModbusTCPServer::terminate()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment