Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Commit a9db659

Browse files
committed
Update exception handling in parallel for sample
The correct exception types are now caught by the catch clauses. Additionally we catch by const&.
1 parent 44c0559 commit a9db659

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

samples/parallel-for/parallel-for.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ int main() {
4444
for (auto ep : l) {
4545
try {
4646
std::rethrow_exception(ep);
47-
} catch (std::exception& e) {
48-
std::cout << e.what();
47+
} catch (const exception& e) {
48+
std::cout << "Asynchronous exception caught:\n" << e.what();
4949
}
5050
}
5151
});
@@ -86,8 +86,8 @@ int main() {
8686
cgh.parallel_for<class assign_elements>(myRange, myKernel);
8787
});
8888

89-
} catch (exception e) {
90-
std::cout << "SYCL exception caught: " << e.what();
89+
} catch (const exception& e) {
90+
std::cout << "Synchronous exception caught:\n" << e.what();
9191
return 2;
9292
}
9393

0 commit comments

Comments
 (0)