Source code: com/aendvari/common/util/ExceptionUtil.java
1 /*
2 * ConversionUtil.java
3 *
4 * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5 *
6 * See the file LICENSE for terms of use.
7 *
8 */
9
10 package com.aendvari.common.util;
11
12 import java.io.*;
13
14 /**
15 * Provides utility methods for handling exceptions.
16 *
17 * @author Trevor Milne
18 *
19 */
20
21 public class ExceptionUtil
22 {
23 /**
24 * Returns the exception stack trace as a string.
25 *
26 * @param exception The <code>Exception</code> to trace.
27 *
28 * @return A string representation of the stack trace.
29 *
30 */
31
32 public static String getStackTrace(Exception exception)
33 {
34 StringWriter buffer = new StringWriter();
35 PrintWriter writer = new PrintWriter(buffer);
36
37 exception.printStackTrace(writer);
38
39 return buffer.toString();
40 }
41 }
42