2004/01/13 10:27:47
[org.ibex.core.git] / src / org / xwt / js / JSExn.java
index 2cc9591..df1022e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] 
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] 
 package org.xwt.js; 
 
 import org.xwt.util.*; 
@@ -8,11 +8,19 @@ import java.util.*;
 
 /** An exception which can be thrown and caught by JavaScript code */
 public class JSExn extends Exception { 
+    private Vec backtrace = new Vec();
     private Object js = null; 
     public JSExn(Object js) { this.js = js; } 
     public String toString() { return "JSExn: " + js; }
     public String getMessage() { return toString(); }
     public Object getObject() { return js; } 
+    public void addBacktrace(String sourceName, int lineNo) { backtrace.addElement(sourceName + ":" + lineNo); }
+    public String backtrace() {
+        StringBuffer sb = new StringBuffer(1024);
+        for(int i=0;i<backtrace.size();i++)
+            sb.append("    at " + (String) backtrace.elementAt(i) + "\n");
+        return sb.toString();
+    }
 } 
 
 /** should only be used for failed coercions */