Skip to content

Commit 22c6818

Browse files
authored
Merge pull request #61 from apple1417/master
throw if construct object fails
2 parents 8f79866 + 9d48c01 commit 22c6818

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

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

21+
- `unrealsdk.construct_object` now throws a `RuntimeError` instead of silently returning `None` when
22+
constructing the object fails. This is how the type hints already assumed it worked.
23+
24+
[264634e2](https://github.com/bl-sdk/pyunrealsdk/commit/264634e2)
25+
2126
### unrealsdk v1.5.0
2227
For reference, the unrealsdk v1.5.0 changes this includes are:
2328

src/pyunrealsdk/base_bindings.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,15 @@ void register_base_bindings(py::module_& mod) {
306306
"construct_object",
307307
[](const std::variant<UClass*, std::wstring>& cls_arg, UObject* outer, const FName& name,
308308
decltype(UObject::ObjectFlags) flags, UObject* template_obj) {
309-
return unrealsdk::construct_object(evaluate_class_arg(cls_arg), outer, name, flags,
310-
template_obj);
309+
auto cls = evaluate_class_arg(cls_arg);
310+
auto val = unrealsdk::construct_object(cls, outer, name, flags, template_obj);
311+
312+
if (val == nullptr) {
313+
throw std::runtime_error(unrealsdk::fmt::format(
314+
"Failed to construct object! cls: {}, outer: {}, name: {}", cls->Name,
315+
unrealsdk::utils::narrow(outer->get_path_name()), name));
316+
}
317+
return val;
311318
},
312319
"Constructs a new object.\n"
313320
"\n"

0 commit comments

Comments
 (0)