浏览代码

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 年之前
父节点
当前提交
9e8cb555f8
共有 1 个文件被更改,包括 8 次插入2 次删除
  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>();