add try catch for function which make often problems to prevent server crash, intead sending email to admin

This commit is contained in:
einhornimmond 2021-05-17 11:31:14 +02:00
parent c7e09da229
commit 1c08e50c39

View File

@ -180,7 +180,9 @@ std::vector<Poco::AutoPtr<controller::PendingTask>> PendingTasksManager::getTran
void PendingTasksManager::checkForFinishedTasks(Poco::Timer& timer)
{
static const char* function_name = "PendingTasksManager::checkForFinishedTasks";
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
try {
for (auto map_it = mPendingTasks.begin(); map_it != mPendingTasks.end(); map_it++)
{
@ -200,12 +202,22 @@ void PendingTasksManager::checkForFinishedTasks(Poco::Timer& timer)
if (removeIt) {
transaction->deleteFromDB();
list_it = list->erase(list_it);
if (!list->size()) break;
if (!list->size() || list_it == list->end()) break;
}
}
}
}
}
catch (Poco::Exception& ex) {
NotificationList errors;
errors.addError(new ParamError(function_name, "poco exception", ex.displayText()));
errors.sendErrorsAsEmail();
} catch(std::exception& ex) {
NotificationList errors;
errors.addError(new ParamError(function_name, "std::exception", ex.what()));
errors.sendErrorsAsEmail();
}
}
Poco::AutoPtr<controller::PendingTask> PendingTasksManager::getPendingTask(int pendingTaskId)
{