Improved error handling.

This commit is contained in:
2018-08-12 10:12:42 +00:00
parent c53386c4f4
commit a51b8955e2
3 changed files with 31 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ void signalCallback(int signum);
volatile bool contProc = true;
int main()
int main(int argc, char **argv)
{
try
{
@@ -21,6 +21,9 @@ int main()
catch (runtime_error &e)
{
cerr << e.what() << endl;
if (getuid() != 0)
cerr << "Try running as root, using \'sudo " << argv[0] << "\'" << endl;
}
signal(SIGINT, signalCallback);
@@ -30,7 +33,19 @@ int main()
while (contProc)
{
ch.handleTransaction();
try
{
ch.handleTransaction();
}
catch (const runtime_error &e)
{
cerr << e.what() << endl;
if (getuid() != 0)
cerr << "Try running as root, using \'sudo " << argv[0] << "\'" << endl;
raise(SIGINT);
return EXIT_FAILURE;
}
usleep(10000);
}
@@ -52,5 +67,5 @@ int main()
void signalCallback([[maybe_unused]] int signum)
{
contProc = false;
clog << "\nCaught SIGINT signal" << endl;
clog << "\nClosing" << endl;
}