2003/11/18 10:47:25
[org.ibex.core.git] / src / org / xwt / js / JSCallable.java
index c9c09d0..ac44c5c 100644 (file)
@@ -7,11 +7,22 @@ public abstract class JSCallable extends JS {
     public static final Object METHOD = new Object();
 
     public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) {
-        throw new JS.Exn("attempted to call an undefined method");
+        if (method == null) return call(a0, a1, a2, rest, nargs);
+        Class c = this.getClass();
+        String descrip = c.getName();
+        if (c == Internal.JSCallableStub.class) {
+            descrip = ((Internal.JSCallableStub)this).obj.getClass().getName();
+        }
+        throw new JS.Exn("attempted to call an undefined method ("+method+") on a " + descrip);
     }
 
     public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) {
-        throw new JS.Exn("you cannot call this object");
+        Class c = this.getClass();
+        String descrip = c.getName();
+        if (c == Internal.JSCallableStub.class) {
+            descrip = ((Internal.JSCallableStub)this).obj.getClass().getName();
+        }
+        throw new JS.Exn("you cannot call this object (of type " + descrip + ")");
     }
 
 }