Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions YantraJS.Core/Core/Object/JSObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ public override JSValue this[KeyString name] {
internal protected override bool SetValue(KeyString name, JSValue value, JSValue receiver, bool throwError = true)
{
var start = this;
var originalName = name.ToStringSpan();
var p = GetInternalProperty(name, true);
if (p.IsProperty)
{
Expand All @@ -503,29 +504,29 @@ internal protected override bool SetValue(KeyString name, JSValue value, JSValue
return true;
}
if (throwError)
throw JSContext.Current.NewTypeError($"Cannot modify property {name} of {this} which has only a getter");
throw JSContext.Current.NewTypeError($"Cannot modify property {originalName} of {this} which has only a getter");
return false;
}
if (p.IsReadOnly)
{
if (throwError)
{
// Only in Strict Mode ..
throw JSContext.Current.NewTypeError($"Cannot modify property {name} of {this}");
throw JSContext.Current.NewTypeError($"Cannot modify property {originalName} of {this}");
}
return false;
}
if (this.IsFrozen())
{
if(throwError)
throw JSContext.Current.NewTypeError($"Cannot modify property {name} of {this}");
throw JSContext.Current.NewTypeError($"Cannot modify property {originalName} of {this}");
return false;
}
if (p.IsEmpty && !this.IsExtensible())
{
if (throwError)
{
throw JSContext.Current.NewTypeError($"Cannot add property {name} to {this}");
throw JSContext.Current.NewTypeError($"Cannot add property {originalName} to {this}");
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion YantraJS.Core/Extensions/JSValueExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static JSValue InvokeMethod(this JSValue @this, in KeyString name, in Arg
{
var fx = @this.GetMethod(in name);
if (fx == null)
throw JSContext.Current.NewTypeError($"Method {name} not found in {@this}");
throw JSContext.Current.NewTypeError($"Method {name.ToStringSpan()} not found in {@this}");
return fx(a.OverrideThis(@this));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static partial class JSValueExtensions
public static JSValue InvokeMethod(this JSValue @this, in KeyString name)
{
var fx = @this.GetMethod(name)
?? throw JSContext.Current.NewTypeError($"Method {name} not found in {@this}");
?? throw JSContext.Current.NewTypeError($"Method {name.ToStringSpan()} not found in {@this}");
var a = new Arguments(@this);
return fx(a);
}
Expand All @@ -23,7 +23,7 @@ public static JSValue InvokeMethod(this JSValue @this, in KeyString name)
public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValue arg0)
{
var fx = @this.GetMethod(name)
?? throw JSContext.Current.NewTypeError($"Method {name} not found in {@this}");
?? throw JSContext.Current.NewTypeError($"Method {name.ToStringSpan()} not found in {@this}");
var a = new Arguments(@this, arg0);
return fx(a);
}
Expand All @@ -32,7 +32,7 @@ public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValu
public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValue arg0, JSValue arg1)
{
var fx = @this.GetMethod(name)
?? throw JSContext.Current.NewTypeError($"Method {name} not found in {@this}");
?? throw JSContext.Current.NewTypeError($"Method {name.ToStringSpan()} not found in {@this}");
var a = new Arguments(@this, arg0, arg1);
return fx(a);
}
Expand All @@ -41,7 +41,7 @@ public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValu
public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValue arg0, JSValue arg1, JSValue arg2)
{
var fx = @this.GetMethod(name)
?? throw JSContext.Current.NewTypeError($"Method {name} not found in {@this}");
?? throw JSContext.Current.NewTypeError($"Method {name.ToStringSpan()} not found in {@this}");
var a = new Arguments(@this, arg0, arg1, arg2);
return fx(a);
}
Expand All @@ -50,7 +50,7 @@ public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValu
public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValue arg0, JSValue arg1, JSValue arg2, JSValue arg3)
{
var fx = @this.GetMethod(name)
?? throw JSContext.Current.NewTypeError($"Method {name} not found in {@this}");
?? throw JSContext.Current.NewTypeError($"Method {name.ToStringSpan()} not found in {@this}");
var a = new Arguments(@this, arg0, arg1, arg2, arg3);
return fx(a);
}
Expand All @@ -59,7 +59,7 @@ public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValu
public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValue[] args)
{
var fx = @this.GetMethod(name)
?? throw JSContext.Current.NewTypeError($"Method {name} not found in {@this}");
?? throw JSContext.Current.NewTypeError($"Method {name.ToStringSpan()} not found in {@this}");
var a = new Arguments(@this, args);
return fx(a);
}
Expand All @@ -68,7 +68,7 @@ public static JSValue InvokeMethod(this JSValue @this, in KeyString name, JSValu
public static JSValue InvokeMethodSpread(this JSValue @this, in KeyString name, JSValue[] args)
{
var fx = @this.GetMethod(name)
?? throw JSContext.Current.NewTypeError($"Method {name} not found in {@this}");
?? throw JSContext.Current.NewTypeError($"Method {name.ToStringSpan()} not found in {@this}");
var length = 0;
foreach ( var item in args)
{
Expand Down
Loading