diff --git a/src/realm/obj.cpp b/src/realm/obj.cpp index f0ca3ee1b7d..fed00ddbab9 100644 --- a/src/realm/obj.cpp +++ b/src/realm/obj.cpp @@ -700,9 +700,7 @@ Mixed Obj::get_additional_prop(StringData prop_name) const return *val; } } - else { - throw InvalidArgument(ErrorCodes::InvalidProperty, util::format("Property not found: %1", prop_name)); - } + throw InvalidArgument(ErrorCodes::InvalidProperty, util::format("Property not found: %1", prop_name)); return {}; } diff --git a/test/test_sync.cpp b/test/test_sync.cpp index a37c2a4216a..783137b28a8 100644 --- a/test/test_sync.cpp +++ b/test/test_sync.cpp @@ -6252,6 +6252,7 @@ TEST(Sync_AdditionalProperties) CHECK_EQUAL(obj.get_any("any"), Mixed("FooBar")); auto list = obj.get_list_ptr({"scores"}); CHECK_EQUAL(list->get(0), Mixed(4.6)); + CHECK_THROW_ANY(obj.get_any("some")); CHECK_THROW_ANY(obj.erase_prop("any")); obj.erase_prop("age"); });