/*
 * ExceptionToString.java
 *
 * Created on 26. cerven 2007, 17:32
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package cz.cuni.amis.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * Simple class that serialize (format) exception to the String allowing you to 
 * specify a message as a prefix of the whole string.
 * 
 * @author Jimmy
 */
public class ExceptionToString {
        
        public static String process(String message, Exception e) {
                StringWriter stringError = new StringWriter();
                PrintWriter printError = new PrintWriter(stringError);
                printError.println(message);
                e.printStackTrace(printError);
                return stringError.toString();
        }
        
        public static String process(Exception e) {
                StringWriter stringError = new StringWriter();
                PrintWriter printError = new PrintWriter(stringError);
                e.printStackTrace(printError);
                return stringError.toString();
        }
        
}
