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