aboutsummaryrefslogtreecommitdiff
path: root/erecht.client.ss/src/at/gv/egovernment/moa/ss/erechtclient/ERechtClientException.java
diff options
context:
space:
mode:
Diffstat (limited to 'erecht.client.ss/src/at/gv/egovernment/moa/ss/erechtclient/ERechtClientException.java')
-rw-r--r--erecht.client.ss/src/at/gv/egovernment/moa/ss/erechtclient/ERechtClientException.java111
1 files changed, 111 insertions, 0 deletions
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 <code>Throwable</code>. */
+ private Throwable wrapped_;
+
+ /**
+ * Create a <code>MOAException</code>.
+ *
+ * @param message The message contained in the created <code>ERechtClientException</code>.
+ */
+ public ERechtClientException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Create a <code>MOAException</code>.
+ *
+ * @param message The message contained in the created <code>ERechtClientException</code>.
+ *
+ * @param wrapped The exception wrapped by the created <code>ERechtClientException</code>.
+ */
+ public ERechtClientException(String message, Throwable wrapped)
+ {
+ super(message, wrapped);
+ this.wrapped_ = wrapped;
+ }
+
+ /**
+ * Print a stack trace of this exception to <code>System.err</code>.
+ *
+ * @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();
+ }
+}