diff --git a/YantraJS.Core/Core/Object/JSObject.cs b/YantraJS.Core/Core/Object/JSObject.cs index 58e59cd6..707b4029 100644 --- a/YantraJS.Core/Core/Object/JSObject.cs +++ b/YantraJS.Core/Core/Object/JSObject.cs @@ -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) { @@ -503,7 +504,7 @@ 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) @@ -511,21 +512,21 @@ internal protected override bool SetValue(KeyString name, JSValue value, JSValue 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; } diff --git a/YantraJS.Core/Extensions/JSValueExtensions.cs b/YantraJS.Core/Extensions/JSValueExtensions.cs index 51a11cc1..bf61b145 100644 --- a/YantraJS.Core/Extensions/JSValueExtensions.cs +++ b/YantraJS.Core/Extensions/JSValueExtensions.cs @@ -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)); } diff --git a/YantraJS.Core/Extensions/JSValueInvokeMethodKeyStringExtensions.cs b/YantraJS.Core/Extensions/JSValueInvokeMethodKeyStringExtensions.cs index 0d1ef9d9..1989a21e 100644 --- a/YantraJS.Core/Extensions/JSValueInvokeMethodKeyStringExtensions.cs +++ b/YantraJS.Core/Extensions/JSValueInvokeMethodKeyStringExtensions.cs @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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) {