1 package org.apache.fulcrum.yaafi.framework.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.PrintWriter;
23 import java.io.StringWriter;
24
25 /**
26 * A subset of the utilities available in commons-lang-2.1 ExceptionUtils.
27 *
28 * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
29 */
30 public class ExceptionUtils
31 {
32
33 /**
34 * <p>Public constructor allows an instance of <code>ExceptionUtils</code>
35 * to be created, although that is not normally necessary.</p>
36 */
37 public ExceptionUtils()
38 {
39
40 }
41
42 /**
43 * <p>Gets the stack trace from a Throwable as a String.</p>
44 *
45 * @param throwable the <code>Throwable</code> to be examined
46 * @return the stack trace as generated by the exception's
47 * <code>printStackTrace(PrintWriter)</code> method
48 */
49 public static String getStackTrace(Throwable throwable)
50 {
51 StringWriter sw = new StringWriter();
52 PrintWriter pw = new PrintWriter( sw, true );
53 throwable.printStackTrace( pw );
54 return sw.getBuffer().toString();
55 }
56 }