01: /*
02: * Created on Aug 5, 2005
03: */
04: package uk.org.ponder.errorutil;
05:
06: import uk.org.ponder.streamutil.write.PrintOutputStream;
07: import uk.org.ponder.xml.XMLWriter;
08:
09: /**
10: * @author Antranig Basman (antranig@caret.cam.ac.uk)
11: *
12: */
13: public class ErrorUtil {
14: public static void dumpStackTrace(Throwable t, PrintOutputStream pos) {
15: pos.println(t.getMessage());
16: StackTraceElement[] elements = t.getStackTrace();
17: for (int i = 0; i < elements.length; ++i) {
18: pos.println(elements[i]);
19: }
20: }
21:
22: public static void dumpStackTraceXML(Throwable t,
23: PrintOutputStream pos) {
24: XMLWriter xmlw = new XMLWriter(pos);
25: xmlw.write(t.getMessage() + "\n");
26: StackTraceElement[] elements = t.getStackTrace();
27: for (int i = 0; i < elements.length; ++i) {
28: xmlw.write(elements[i] + "\n");
29: }
30: }
31: }
|