/** log a message with the current JavaScript sourceName/line */
public static void log(Object o, Object message) { log(message); }
public static void log(Object message) { Log.echo(JS.getSourceName() + ":" + JS.getLine(), message); }
+ public static void log(JSExn e) {
+ Log.echo(e,"JS Exception: " + e.getObject() + "\n" + e.backtrace());
+ Log.echo(e,e);
+ }
public static int getLine() {
Interpreter c = Interpreter.current();
/** override and return true to allow placing traps on this object.
* if isRead true, this is a read trap, otherwise write trap
**/
- protected boolean isTrappable(Object name, boolean isRead) { return false; }
+ protected boolean isTrappable(Object name, boolean isRead) { return true; }
/** performs a put, triggering traps if present; traps are run in an unpauseable interpreter */
public void putAndTriggerTraps(Object key, Object value) throws JSExn {
// Typing Support //////////////////////////////////////////////////////////////////////////////
- public Number coerceToNumber() { throw new JSRuntimeExn("tried to coerce a JavaScript object to a Number"); }
- public String coerceToString() { throw new JSRuntimeExn("tried to coerce a JavaScript object to a String"); }
- public boolean coerceToBoolean() { throw new JSRuntimeExn("tried to coerce a JavaScript object to a Boolean"); }
+ public Number coerceToNumber() { throw new JSRuntimeExn("tried to coerce a JavaScript object of type " +
+ getClass().getName() + " to a Number"); }
+ public String coerceToString() { throw new JSRuntimeExn("tried to coerce a JavaScript object of type " +
+ getClass().getName() + " to a String"); }
+ public boolean coerceToBoolean() { throw new JSRuntimeExn("tried to coerce a JavaScript object of type " +
+ getClass().getName() + " to a Boolean"); }
public String typeName() { return "object"; }