/**
 * 
 */
package com.ejie.ad74a.exception;

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

/**
 * Excepcion prepara para la aplicacion ad74a.
 * 
 * @author jhidalgo
 *
 */
public class Ad74aException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3591696768155921062L;

	/**
	 * 
	 */
	public Ad74aException() {
		// Por defecto
	}

	/**
	 * @param paramString
	 */
	public Ad74aException(String paramString) {
		super(paramString);
	}

	/**
	 * @param paramThrowable
	 */
	public Ad74aException(Throwable paramThrowable) {
		super(paramThrowable);
	}

	/**
	 * @param paramString
	 * @param paramThrowable
	 */
	public Ad74aException(String paramString, Throwable paramThrowable) {
		super(paramString, paramThrowable);
	}
	
	/**
     * M�todo que permite recuperar el StackTrace de una exception en formato string
     * @param e, Throwable
     * @return String con el StackTrace de la exception...
     */
	public static String escribirStackTrace ( Throwable e) { 
		StringWriter stringWritter = new StringWriter();//crea un  StringWritter
		PrintWriter printWritter = new PrintWriter(stringWritter, true); //crea un  printWriter para ese StringWritter
		e.printStackTrace(printWritter); //pinta el stackTrace mediante el  printWritter (en vez de hacerlo mediante la salida standard)
		printWritter.flush();
		stringWritter.flush(); 
		return stringWritter.toString();
	}

}
