mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 06:46:03 +00:00
Non-existent object getters shouldn't throw exceptions
This commit is contained in:
parent
8e1eb661c5
commit
0511bade62
@ -34,9 +34,7 @@ JSValueRef ObjectGetProperty(JSContextRef ctx, JSObjectRef jsObject, JSStringRef
|
||||
Object *obj = RJSGetInternal<Object *>(jsObject);
|
||||
return obj->get_property_value<JSValueRef>(ctx, RJSStringForJSString(jsPropertyName));
|
||||
} catch (std::exception &ex) {
|
||||
if (exception) {
|
||||
*exception = RJSMakeError(ctx, ex);
|
||||
}
|
||||
// getters for nonexistent properties in JS should always return undefined
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ namespace realm {
|
||||
{
|
||||
const Property *prop = object_schema.property_for_name(prop_name);
|
||||
if (!prop) {
|
||||
throw std::runtime_error("Setting invalid property '" + prop_name + "' on object '" + object_schema.name + "'.");
|
||||
throw std::runtime_error("Getting invalid property '" + prop_name + "' on object '" + object_schema.name + "'.");
|
||||
}
|
||||
return get_property_value_impl<ValueType>(ctx, *prop);
|
||||
};
|
||||
|
@ -44,6 +44,8 @@ module.exports = BaseTest.extend({
|
||||
TestCase.assertEqual(object[prop.name], basicTypesValues[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TestCase.assertEqual(object.nonexistent, undefined);
|
||||
},
|
||||
testBasicTypesPropertySetters: function() {
|
||||
var basicTypesValues = [true, 1, 1.1, 1.11, 'string', new Date(1), 'DATA'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user