Report error to wren if an exception is thrown
This commit is contained in:
parent
e5d85e8f40
commit
b559f025e9
1 changed files with 9 additions and 2 deletions
|
@ -220,8 +220,15 @@ 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));
|
||||
T* const obj = new(mem) T{std::forward<Args>(args)...};
|
||||
return obj;
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue