Browse Source

set message to TypeError when method is not found

Set message to TypeError when method is not found based on V8 error
messages
Frederic Torres 11 năm trước cách đây
mục cha
commit
9e8cb555f8
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      Jint/Runtime/ExpressionIntepreter.cs

+ 8 - 2
Jint/Runtime/ExpressionIntepreter.cs

@@ -797,12 +797,18 @@ namespace Jint.Runtime
 
             if (func == Undefined.Instance)
             {
-                throw new JavaScriptException(_engine.TypeError);
+                if ((callee as Reference) == null)
+                    throw new JavaScriptException(_engine.TypeError);
+                else
+                    throw new JavaScriptException(_engine.TypeError, string.Format("Object has no method '{0}'", (callee as Reference).GetReferencedName()));
             }
 
             if (!func.IsObject())
             {
-                throw new JavaScriptException(_engine.TypeError);
+                if ((callee as Reference) == null)
+                    throw new JavaScriptException(_engine.TypeError);
+                else
+                    throw new JavaScriptException(_engine.TypeError, string.Format("Property '{0}' of object is not a function", (callee as Reference).GetReferencedName()));
             }
 
             var callable = func.TryCast<ICallable>();