#5 better error handling, do not leave the program in a dangling state

pull/32/head
Geoffrey Merck 4 years ago
parent 3ed0d18dc3
commit eba2334050

@ -201,9 +201,11 @@ void* CAPRSHandlerThread::Entry()
catch (std::exception& e) {
std::string message(e.what());
CLog::logInfo("Exception raised in the APRS Writer thread - \"%s\"", message.c_str());
throw;
}
catch (...) {
CLog::logInfo("Unknown exception raised in the APRS Writer thread");
throw;
}
#endif

@ -90,9 +90,11 @@ void* CDPlusAuthenticator::Entry()
catch (std::exception& e) {
std::string message(e.what());
CLog::logError("Exception raised in the D-Plus Authenticator thread - \"%s\"", message.c_str());
throw;
}
catch (...) {
CLog::logError("Unknown exception raised in the D-Plus Authenticator thread");
throw;
}
#endif

@ -54,11 +54,10 @@ int main(int argc, char *argv[])
{
std::set_terminate(CDStarGatewayApp::terminateHandler);
// TODO 2022-01-17 handle SIGTERM etc ....
// signal(SIGSEGV, CDStarGatewayApp::sigHandler);
// signal(SIGILL, CDStarGatewayApp::sigHandler);
// signal(SIGFPE, CDStarGatewayApp::sigHandler);
// signal(SIGABRT, CDStarGatewayApp::sigHandler);
signal(SIGSEGV, CDStarGatewayApp::sigHandlerFatal);
signal(SIGILL, CDStarGatewayApp::sigHandlerFatal);
signal(SIGFPE, CDStarGatewayApp::sigHandlerFatal);
signal(SIGABRT, CDStarGatewayApp::sigHandlerFatal);
// signal(SIGTERM, CDStarGatewayApp::sigHandler);
setbuf(stdout, NULL);
@ -276,9 +275,15 @@ bool CDStarGatewayApp::createThread()
return true;
}
void CDStarGatewayApp::sigHandler(int /*sig*/)
void CDStarGatewayApp::sigHandlerFatal(int sig)
{
// TODO 2022-01-17 handle SIGTERM etc ....
CLog::logFatal("Caught signal : %s", strsignal(sig));
#ifdef DEBUG_DSTARGW
std::stringstream stackTrace;
stackTrace << boost::stacktrace::stacktrace();
CLog::logFatal("Stack Trace : \n%s", stackTrace.str().c_str());
#endif
exit(1);
}
void CDStarGatewayApp::terminateHandler()
@ -297,14 +302,14 @@ void CDStarGatewayApp::terminateHandler()
std::rethrow_exception(eptr);
}
else {
CLog::logFatal("Unhandled unkown exception occured");
CLog::logFatal("Unhandled unknown exception occured");
}
} catch(const std::exception& e) {
CLog::logFatal("Unhandled exception occured %s", e.what());
}
#ifdef DEBUG_DSTARGW
CLog::logFatal("%s", stackTrace.str().c_str());
CLog::logFatal("Stack Trace : \n%s", stackTrace.str().c_str());
#endif
exit(1);
}

@ -37,6 +37,6 @@ public:
bool init();
void run();
static void sigHandler(int sig);
static void sigHandlerFatal(int sig);
static void terminateHandler();
};

@ -418,9 +418,11 @@ void* CDStarGatewayThread::Entry()
catch (std::exception& e) {
std::string message(e.what());
CLog::logFatal("Exception raised in the main thread - \"%s\"", message.c_str());
throw;
}
catch (...) {
CLog::logFatal("Unknown exception raised in the main thread");
throw;
}
#endif

@ -152,9 +152,11 @@ void* CIcomRepeaterProtocolHandler::Entry()
catch (std::exception& e) {
std::string message(e.what());
CLog::logError("Exception raised in the Icom Controller thread - \"%s\"", message.c_str());
throw;
}
catch (...) {
CLog::logError("Unknown exception raised in the Icom Controller thread");
throw;
}
#endif

Loading…
Cancel
Save

Powered by TurnKey Linux.