Skip to content

Commit

Permalink
Add a default exception handler to the live listener background thread
Browse files Browse the repository at this point in the history
If the background thread ever throws an uncaught excetion, it will
silently exit.  The default handler catches everything and logs a fatal
error before the thread exits.

Refs #5857
  • Loading branch information
rgmiller committed Oct 5, 2012
1 parent 96ab543 commit b9f87ad
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ namespace DataHandling

void SNSLiveEventDataListener::run()
{
try {
if (m_isConnected == false) // sanity check
{
throw std::runtime_error( std::string("SNSLiveEventDataListener::run(): No connection to SMS server."));
Expand Down Expand Up @@ -187,6 +188,24 @@ namespace DataHandling
}
}

} catch (...) { // Default exception handler
// If we've gotten here, it's because the thread has thrown an otherwise
// uncaught exception. In such a case, the thread will exit and there's
// nothing we can do about that. The only thing we can do is log an error
// so hopefully the user will notice (instead of wonder why all the
// incoming data has just stopped...)
g_log.fatal() << "Uncaught exception in SNSLiveEventDataListener network read thread."
<< " Thread is exiting." << std::endl;
m_isConnected = false;

// The extractData() function is deliberately designed to block until the workspace is
// initialized so we have to ensure the flag is set or else the entire GUI will lock up.
// Note that if the workspace really hasn't been initialized, then the values in it are
// going to be completely bogus, but since the entire we're not going to be able to read
// any data, that's not really an issue.
m_workspaceInitialized = true;
}

return;
}

Expand Down

0 comments on commit b9f87ad

Please sign in to comment.