فهرست منبع

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>();