Move all code in `run()` function into try-blocks for consistent error handling
This commit is contained in:
parent
9113015294
commit
b3dd694a1c
|
@ -785,36 +785,38 @@ int ServiceSetup::run()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printDatabases();
|
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
||||||
|
try {
|
||||||
cout << Phrases::SuccessMessage << "Initializing SSL" << Phrases::End;
|
#else
|
||||||
webServer.initSsl();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
|
printDatabases();
|
||||||
|
|
||||||
|
cout << Phrases::SuccessMessage << "Initializing SSL" << Phrases::End;
|
||||||
|
webServer.initSsl();
|
||||||
|
|
||||||
cout << Phrases::SuccessMessage << "Allocating worker thread pool (thread count: " << building.threadCount << ")" << Phrases::End;
|
cout << Phrases::SuccessMessage << "Allocating worker thread pool (thread count: " << building.threadCount << ")" << Phrases::End;
|
||||||
const auto buildWorker = building.allocateBuildWorker();
|
const auto buildWorker = building.allocateBuildWorker();
|
||||||
|
|
||||||
|
cout << Phrases::SuccessMessage << "Starting web server (thread count: " << webServer.threadCount << "):" << TextAttribute::Reset
|
||||||
|
<< " http://" << webServer.address << ':' << webServer.port << endl;
|
||||||
|
WebAPI::Server::serve(*this);
|
||||||
|
cout << Phrases::SuccessMessage << "Web server stopped." << Phrases::EndFlush;
|
||||||
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
||||||
try {
|
} catch (const boost::exception &e) {
|
||||||
#endif
|
cerr << Phrases::ErrorMessage << "Server terminated due to exception: " << Phrases::End << " " << boost::diagnostic_information(e)
|
||||||
cout << Phrases::SuccessMessage << "Starting web server (thread count: " << webServer.threadCount << "):" << TextAttribute::Reset
|
<< Phrases::EndFlush;
|
||||||
<< " http://" << webServer.address << ':' << webServer.port << endl;
|
return -3;
|
||||||
WebAPI::Server::serve(*this);
|
} catch (const std::exception &e) {
|
||||||
cout << Phrases::SuccessMessage << "Web server stopped." << Phrases::EndFlush;
|
cerr << Phrases::ErrorMessage << "Server terminated due to exception: " << Phrases::End << " " << e.what() << Phrases::EndFlush;
|
||||||
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
return -3;
|
||||||
} catch (const boost::exception &e) {
|
} catch (...) {
|
||||||
cerr << Phrases::ErrorMessage << "Server terminated due to exception: " << Phrases::End << " " << boost::diagnostic_information(e)
|
cerr << Phrases::ErrorMessage << "Server terminated due to an unknown error." << Phrases::EndFlush;
|
||||||
<< Phrases::EndFlush;
|
return -4;
|
||||||
return -3;
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
cerr << Phrases::ErrorMessage << "Server terminated due to exception: " << Phrases::End << " " << e.what() << Phrases::EndFlush;
|
|
||||||
return -3;
|
|
||||||
} catch (...) {
|
|
||||||
cerr << Phrases::ErrorMessage << "Server terminated due to an unknown error." << Phrases::EndFlush;
|
|
||||||
return -4;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue