Skip to content
Snippets Groups Projects
Commit abe05dbd authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

manager: catch exceptions in mainloop

This patch prevents exceptions to crash application
if happen during pollEvents() processing.
Exception are just catch and displayed.
In case of exception caused by a task, this one
is removed from pending list.
Handlers are not removed, take care of that!

Change-Id: I266539585baf68f329d53f3d20361c4cb08211f3
Tuleap: #200
parent 2def1015
Branches
Tags
No related merge requests found
...@@ -1407,7 +1407,11 @@ void Manager::pollEvents() ...@@ -1407,7 +1407,11 @@ void Manager::pollEvents()
// Think twice before modify this code. // Think twice before modify this code.
nextEventHandler_ = std::next(iter); nextEventHandler_ = std::next(iter);
try {
iter->second(); iter->second();
} catch (const std::exception& e) {
RING_ERR("MainLoop exception (handler): %s", e.what());
}
iter = nextEventHandler_; iter = nextEventHandler_;
} }
} }
...@@ -1422,7 +1426,14 @@ void Manager::pollEvents() ...@@ -1422,7 +1426,14 @@ void Manager::pollEvents()
return; return;
auto next = std::next(iter); auto next = std::next(iter);
if (not (*iter)()) bool result;
try {
result = (*iter)();
} catch (const std::exception& e) {
RING_ERR("MainLoop exception (task): %s", e.what());
result = false;
}
if (not result)
tmpList.erase(iter); tmpList.erase(iter);
iter = next; iter = next;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment