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