From 1c900609d64445040e8c5bdbfa01ae1a0f563f43 Mon Sep 17 00:00:00 2001 From: gregor Date: Wed, 28 Feb 2007 13:17:57 +0000 Subject: Initial commit git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@806 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../moa/ss/erechtclient/ERechtClientException.java | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 erecht.client.ss/src/at/gv/egovernment/moa/ss/erechtclient/ERechtClientException.java (limited to 'erecht.client.ss/src/at/gv/egovernment/moa/ss/erechtclient/ERechtClientException.java') diff --git a/erecht.client.ss/src/at/gv/egovernment/moa/ss/erechtclient/ERechtClientException.java b/erecht.client.ss/src/at/gv/egovernment/moa/ss/erechtclient/ERechtClientException.java new file mode 100644 index 000000000..1650e1641 --- /dev/null +++ b/erecht.client.ss/src/at/gv/egovernment/moa/ss/erechtclient/ERechtClientException.java @@ -0,0 +1,111 @@ +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(); + } +} -- cgit v1.2.3