File size: 865 Bytes
00df61d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <emscripten/val.h>
#include <iostream>
using namespace emscripten;
int main() {
val error;
try {
throw std::runtime_error("oopsie");
} catch (const std::runtime_error&) {
error = val::take_ownership(
emscripten::internal::_emval_from_current_cxa_exception());
}
try {
error.throw_();
} catch (const std::runtime_error& ex) {
std::clog << "Caught1: " << ex.what() << '\n';
}
try {
throw std::runtime_error("oopsie");
} catch (const std::runtime_error&) {
error = val::take_ownership(
emscripten::internal::_emval_from_current_cxa_exception());
}
try {
throw std::runtime_error("this is bad");
} catch (const std::runtime_error&) {
try {
error.throw_(); // Rethrow oopsie
} catch (const std::runtime_error& ex) {
std::clog << "Caught2: " << ex.what() << '\n';
}
}
}
|