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 years ago
parent
commit
9e8cb555f8
1 changed files with 8 additions and 2 deletions
  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>();