Fix uncaught exceptions

This commit is contained in:
Alexey Rybalchenko 2015-06-19 09:56:01 +02:00
parent d6a413534a
commit e5313d03fe
3 changed files with 49 additions and 33 deletions

View File

@ -141,7 +141,7 @@ install(FILES ${FAIRMQHEADERS} DESTINATION include)
set(DEPENDENCIES set(DEPENDENCIES
${DEPENDENCIES} ${DEPENDENCIES}
boost_thread boost_timer boost_system boost_program_options boost_random boost_chrono boost_thread boost_timer boost_system boost_program_options boost_random boost_chrono boost_exception
) )
set(LIBRARY_NAME FairMQ) set(LIBRARY_NAME FairMQ)

View File

@ -12,6 +12,8 @@
* @author D. Klein, A. Rybalchenko * @author D. Klein, A. Rybalchenko
*/ */
#include <boost/exception/all.hpp>
#include <boost/chrono.hpp> // for WaitForEndOfStateForMs() #include <boost/chrono.hpp> // for WaitForEndOfStateForMs()
#include "FairMQStateMachine.h" #include "FairMQStateMachine.h"
@ -96,9 +98,9 @@ bool FairMQStateMachine::ChangeState(int event)
return false; return false;
} }
} }
catch (std::exception& e) catch (boost::exception &e)
{ {
LOG(ERROR) << e.what(); LOG(ERROR) << boost::diagnostic_information(e);
} }
} }
@ -109,6 +111,8 @@ bool FairMQStateMachine::ChangeState(std::string event)
void FairMQStateMachine::WaitForEndOfState(int event) void FairMQStateMachine::WaitForEndOfState(int event)
{ {
try
{
switch (event) switch (event)
{ {
case INIT_DEVICE: case INIT_DEVICE:
@ -128,6 +132,11 @@ void FairMQStateMachine::WaitForEndOfState(int event)
LOG(ERROR) << "Requested state is either synchronous or does not exist."; LOG(ERROR) << "Requested state is either synchronous or does not exist.";
break; break;
} }
}
catch (boost::exception &e)
{
LOG(ERROR) << boost::diagnostic_information(e);
}
} }
void FairMQStateMachine::WaitForEndOfState(std::string event) void FairMQStateMachine::WaitForEndOfState(std::string event)
@ -137,6 +146,8 @@ void FairMQStateMachine::WaitForEndOfState(std::string event)
bool FairMQStateMachine::WaitForEndOfStateForMs(int event, int durationInMs) bool FairMQStateMachine::WaitForEndOfStateForMs(int event, int durationInMs)
{ {
try
{
switch (event) switch (event)
{ {
case INIT_DEVICE: case INIT_DEVICE:
@ -159,7 +170,12 @@ bool FairMQStateMachine::WaitForEndOfStateForMs(int event, int durationInMs)
} }
default: default:
LOG(ERROR) << "Requested state is either synchronous or does not exist."; LOG(ERROR) << "Requested state is either synchronous or does not exist.";
break; return false;
}
}
catch (boost::exception &e)
{
LOG(ERROR) << boost::diagnostic_information(e);
} }
} }