Report error to wren if an exception is thrown

This commit is contained in:
King_DuckZ 2022-05-25 11:30:44 +02:00
parent e5d85e8f40
commit b559f025e9

View file

@ -220,9 +220,16 @@ namespace wren {
inline T* make_wren_object(VM& vm, ModuleAndName mn, Args&&... args) {
variable(vm, mn, 0);
void* const mem = vm.set_slot_new_foreign(0, 0, sizeof(T));
try {
T* const obj = new(mem) T{std::forward<Args>(args)...};
return obj;
}
catch (const std::runtime_error& err) {
set(vm, 1, err.what());
vm.abort_fiber(1);
return nullptr;
}
}
#if defined(WRENPP_WITH_NAME_GUESSING)
template <typename T, dhandy::bt::string Mod, typename... Args>