Merge pull request #21579 from TolyaTalamanov:at/handle-errors-in-iebackend

[G-API] Handle errors in IEBackend & modeling tool

* Handle errors in IEBackend & modeling tool

* Handle exceptions in callback

* Add const cv to exception
This commit is contained in:
Anatoliy Talamanov
2022-02-09 19:52:23 +03:00
committed by GitHub
parent 3eeec4faae
commit 619b6dfae3
4 changed files with 95 additions and 14 deletions
@@ -379,10 +379,15 @@ int main(int argc, char* argv[]) {
}
// NB: Execute pipelines
std::vector<std::exception_ptr> eptrs(pipelines.size(), nullptr);
std::vector<std::thread> threads(pipelines.size());
for (size_t i = 0; i < pipelines.size(); ++i) {
threads[i] = std::thread([&, i]() {
pipelines[i]->run(work_time_ms);
try {
pipelines[i]->run(work_time_ms);
} catch (...) {
eptrs[i] = std::current_exception();
}
});
}
@@ -393,12 +398,22 @@ int main(int argc, char* argv[]) {
for (size_t i = 0; i < threads.size(); ++i) {
threads[i].join();
}
for (size_t i = 0; i < threads.size(); ++i) {
if (eptrs[i] != nullptr) {
try {
std::rethrow_exception(eptrs[i]);
} catch (std::exception& e) {
throw std::logic_error(pipelines[i]->name() + " failed: " + e.what());
}
}
if (file.is_open()) {
file << pipelines[i]->report().toStr(true) << std::endl;
}
std::cout << pipelines[i]->report().toStr() << std::endl;
}
} catch (std::exception& e) {
} catch (const std::exception& e) {
std::cout << e.what() << std::endl;
throw;
}