- private Object js = null;
- public JSExn(Object js) { this.js = js; }
- public String toString() { return "JSExn: " + js; }
+ private JS js;
+ public JSExn(String s) { this(JS.S(s)); }
+ public JSExn(JS js) { this(js,null); }
+ public JSExn(JS js, Interpreter cx) { this.js = js; fill(cx); }
+
+ private void fill(Interpreter cx) {
+ if(cx == null) cx = Interpreter.current();
+ if(cx == null) return;
+ addBacktrace(cx.f.sourceName + ":" + cx.f.line[cx.pc]);
+ cx.stack.backtrace(this);
+ }
+ public void printStackTrace() { printStackTrace(System.err); }
+ public void printStackTrace(PrintWriter pw) {
+ for(int i=0; i<backtrace.size(); i++) pw.println(" at " + (String) backtrace.elementAt(i));
+ super.printStackTrace(pw);
+ }
+ public void printStackTrace(PrintStream ps) {
+ for(int i=0; i<backtrace.size(); i++) ps.println(" at " + (String) backtrace.elementAt(i));
+ super.printStackTrace(ps);
+ }
+ public String toString() { return "JSExn: " + JS.debugToString(js); }