1 // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
4 import org.ibex.util.*;
6 /** An exception which can be thrown and caught by JavaScript code */
7 public class JSExn extends Exception {
8 private Vec backtrace = new Vec();
9 private Object js = null;
10 public JSExn(Object js) { this.js = js; }
11 public String toString() { return "JSExn: " + js; }
12 public String getMessage() { return toString(); }
13 public Object getObject() { return js; }
14 public void addBacktrace(String sourceName, int lineNo) { backtrace.addElement(sourceName + ":" + lineNo); }
15 public String backtrace() {
16 StringBuffer sb = new StringBuffer(1024);
17 for(int i=0;i<backtrace.size();i++)
18 sb.append(" at " + (String) backtrace.elementAt(i) + "\n");
23 /** should only be used for failed coercions */
24 class JSRuntimeExn extends RuntimeException {
25 private Object js = null;
26 public JSRuntimeExn(Object js) { this.js = js; }
27 public String toString() { return "JSRuntimeExn: " + js; }
28 public String getMessage() { return toString(); }
29 public Object getObject() { return js; }