Shows how to use std::exception_ptr and invalid_operation_exception exception.
#include <xtd/xtd>
auto main() -> int {
auto exception_pointer = std::exception_ptr {};
auto thread1 = thread {[&] {
try {
throw invalid_operation_exception("Ouch there are an exception !");
} catch (...) {
exception_pointer = std::current_exception();
}
}};
thread1.start();
thread1.join();
if (exception_pointer) {
try {
rethrow_exception(exception_pointer);
} catch (const system_exception& e) {
console::write_line(e);
}
}
}