[Mulgara-svn] r1124 - trunk/src/jar/util/java/org/mulgara/util
pag at mulgara.org
pag at mulgara.org
Sun Aug 10 01:59:59 UTC 2008
Author: pag
Date: 2008-08-09 18:59:58 -0700 (Sat, 09 Aug 2008)
New Revision: 1124
Modified:
trunk/src/jar/util/java/org/mulgara/util/StackTrace.java
Log:
Added in a static utility method to print an arbitrary throwable's stack trace to a string
Modified: trunk/src/jar/util/java/org/mulgara/util/StackTrace.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/StackTrace.java 2008-08-10 01:58:55 UTC (rev 1123)
+++ trunk/src/jar/util/java/org/mulgara/util/StackTrace.java 2008-08-10 01:59:58 UTC (rev 1124)
@@ -12,6 +12,9 @@
package org.mulgara.util;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
/**
* Creates a stack trace for the current position at creation, or from a provided
* Throwable object.
@@ -91,4 +94,15 @@
return b.toString();
}
+ /**
+ * Converts a throwable to a string. This appears an Exception/Error/etc
+ * instead of using the STACK TRACE label.
+ * @param t The Throwable to print.
+ * @return A String with the output from the Throwable.
+ */
+ public static String throwableToString(Throwable t) {
+ StringWriter strWriter = new StringWriter();
+ t.printStackTrace(new PrintWriter(strWriter));
+ return strWriter.toString();
+ }
}
More information about the Mulgara-svn
mailing list