// Copyright 2000-2005 the Contributors, as shown in the revision logs. // Licensed under the Apache Public Source License 2.0 ("the License"). // You may not use this file except in compliance with the License. package org.ibex.js; import org.ibex.util.*; import java.io.*; /** An exception which can be thrown and caught by JavaScript code */ public class JSExn extends Exception { private Basket.List backtrace = new Basket.Array(); private JS js; public JSExn(String s) { this(JSU.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