import java.io.*;

/**
 * Class <code>StackTrace</code> provides one static
 * method to return the stack trace of a
 * <code>Throwable</code> as a <code>String</code>.
 */
public class StackTrace {
    
    /**
     * Returns the stack trace of the given
     * <code>Throwable</code> as a <code>String</code>
     * 
     * @param t the Throwable
     */
    public static String getTrace(Throwable t) {
        if (t == null)
            return "Null Throwable passed to StackTrace.getTrace";
        
        StringWriter writer = new StringWriter();
        
        PrintWriter printwriter = new PrintWriter(writer);
        
        t.printStackTrace(printwriter);
        
        return writer.toString();
    }
    
}

