Move all code in `run()` function into try-blocks for consistent error handling

This commit is contained in:
Martchus 2023-06-03 17:10:15 +02:00
parent 9113015294
commit b3dd694a1c
1 changed files with 26 additions and 24 deletions

View File

@ -785,18 +785,19 @@ int ServiceSetup::run()
}
#endif
#ifndef CPP_UTILITIES_DEBUG_BUILD
try {
#else
{
#endif
printDatabases();
cout << Phrases::SuccessMessage << "Initializing SSL" << Phrases::End;
webServer.initSsl();
{
cout << Phrases::SuccessMessage << "Allocating worker thread pool (thread count: " << building.threadCount << ")" << Phrases::End;
const auto buildWorker = building.allocateBuildWorker();
#ifndef CPP_UTILITIES_DEBUG_BUILD
try {
#endif
cout << Phrases::SuccessMessage << "Starting web server (thread count: " << webServer.threadCount << "):" << TextAttribute::Reset
<< " http://" << webServer.address << ':' << webServer.port << endl;
WebAPI::Server::serve(*this);
@ -813,8 +814,9 @@ int ServiceSetup::run()
cerr << Phrases::ErrorMessage << "Server terminated due to an unknown error." << Phrases::EndFlush;
return -4;
}
#endif
#else
}
#endif
#ifndef CPP_UTILITIES_DEBUG_BUILD
try {