Skip to content

Commit

Permalink
Merge pull request #61 from apple1417/master
Browse files Browse the repository at this point in the history
throw if construct object fails
  • Loading branch information
apple1417 authored Dec 30, 2024
2 parents 8f79866 + 9d48c01 commit 22c6818
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

[ecde0a83](https://github.com/bl-sdk/pyunrealsdk/commit/ecde0a83)

- `unrealsdk.construct_object` now throws a `RuntimeError` instead of silently returning `None` when
constructing the object fails. This is how the type hints already assumed it worked.

[264634e2](https://github.com/bl-sdk/pyunrealsdk/commit/264634e2)

### unrealsdk v1.5.0
For reference, the unrealsdk v1.5.0 changes this includes are:

Expand Down
11 changes: 9 additions & 2 deletions src/pyunrealsdk/base_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,15 @@ void register_base_bindings(py::module_& mod) {
"construct_object",
[](const std::variant<UClass*, std::wstring>& cls_arg, UObject* outer, const FName& name,
decltype(UObject::ObjectFlags) flags, UObject* template_obj) {
return unrealsdk::construct_object(evaluate_class_arg(cls_arg), outer, name, flags,
template_obj);
auto cls = evaluate_class_arg(cls_arg);
auto val = unrealsdk::construct_object(cls, outer, name, flags, template_obj);

if (val == nullptr) {
throw std::runtime_error(unrealsdk::fmt::format(
"Failed to construct object! cls: {}, outer: {}, name: {}", cls->Name,
unrealsdk::utils::narrow(outer->get_path_name()), name));
}
return val;
},
"Constructs a new object.\n"
"\n"
Expand Down

0 comments on commit 22c6818

Please sign in to comment.