package at.gv.egovernment.moa.ss.erechtclient;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Writer;
import javax.servlet.ServletOutputStream;
/**
* Base class of MOA specific exceptions.
*
* This class has the ability to wrap other exceptions which may be seen
* as the root cause for this exception.
*
* @author Gregor Karlinger
* @version $Id$
*/
public class ERechtClientException extends Exception {
/** The wrapped Throwable
. */
private Throwable wrapped_;
/**
* Create a MOAException
.
*
* @param message The message contained in the created ERechtClientException
.
*/
public ERechtClientException(String message)
{
super(message);
}
/**
* Create a MOAException
.
*
* @param message The message contained in the created ERechtClientException
.
*
* @param wrapped The exception wrapped by the created ERechtClientException
.
*/
public ERechtClientException(String message, Throwable wrapped)
{
super(message, wrapped);
this.wrapped_ = wrapped;
}
/**
* Print a stack trace of this exception to System.err
.
*
* @see java.lang.Throwable#printStackTrace()
*/
public void printStackTrace()
{
printStackTrace(System.err);
}
/**
* Print a stack trace of this exception, including the wrapped exception.
*
* @param s The stream to write the stack trace to.
*
* @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
*/
public void printStackTrace(PrintStream s)
{
super.printStackTrace(s);
if (wrapped_ != null)
{
s.print("Caused by: ");
wrapped_.printStackTrace(s);
}
}
/**
* Print a stack trace of this exception, including the wrapped exception.
*
* @param s The stream to write the stacktrace to.
*
* @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
*/
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
if (wrapped_ != null)
{
s.print("Caused by: ");
wrapped_.printStackTrace(s);
}
}
/**
* Print a stack trace of this exception, including the wrapped exception.
*
* @param s The stream to write the stacktrace to.
*
* @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
*/
public String getStackTracePrint()
{
ByteArrayOutputStream bAOS = new ByteArrayOutputStream();
PrintWriter s = new PrintWriter(bAOS);
super.printStackTrace(s);
if (wrapped_ != null)
{
s.print("Caused by: ");
wrapped_.printStackTrace(s);
}
s.flush();
return bAOS.toString();
}
}