New helper function for abort_fiber + message
This commit is contained in:
parent
b559f025e9
commit
616381516b
3 changed files with 12 additions and 7 deletions
|
@ -143,14 +143,14 @@ namespace wren {
|
|||
|
||||
const auto result = detail::ForeignClassHelper<T, Args...>::construct(vm, vm.slot_count() - 1, mem);
|
||||
if (not result.success) {
|
||||
set(vm, 1, std::string{"No registered c++ constructor "} +
|
||||
abort_fiber_with_error(vm, 1,
|
||||
std::string{"No registered c++ constructor "} +
|
||||
#if defined(WRENPP_WITH_NAME_GUESSING)
|
||||
"for class " + guess_class_name<T>() + " " +
|
||||
#endif
|
||||
"takes " + std::to_string(result.parameter_count) +
|
||||
" parameter" + (result.parameter_count == 1 ? "" : "s")
|
||||
);
|
||||
vm.abort_fiber(1);
|
||||
}
|
||||
};
|
||||
ret.finalize = [](void* mem) {
|
||||
|
|
|
@ -58,6 +58,7 @@ namespace wren {
|
|||
void variable(VM& vm, const Handle& handle, int slot);
|
||||
void variable_ensure_slot(VM& vm, ModuleAndName mod_and_name, int slot);
|
||||
void variable_ensure_slot(VM& vm, const Handle& handle, int slot);
|
||||
void abort_fiber_with_error (VM& vm, int slot, std::string_view message);
|
||||
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
|
@ -225,8 +226,7 @@ namespace wren {
|
|||
return obj;
|
||||
}
|
||||
catch (const std::runtime_error& err) {
|
||||
set(vm, 1, err.what());
|
||||
vm.abort_fiber(1);
|
||||
abort_fiber_with_error(vm, 1, err.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,4 +89,9 @@ namespace wren {
|
|||
vm.ensure_slots(1);
|
||||
variable(vm, handle, slot);
|
||||
}
|
||||
|
||||
void abort_fiber_with_error (VM& vm, int slot, std::string_view message) {
|
||||
set(vm, slot, message);
|
||||
vm.abort_fiber(slot);
|
||||
}
|
||||
} //namespace wren
|
||||
|
|
Loading…
Reference in a new issue