01: package org.exolab.castor.core.exceptions;
02:
03: import java.io.PrintStream;
04: import java.io.PrintWriter;
05:
06: public final class CastorIllegalStateException extends
07: IllegalStateException {
08: /** SerialVersionUID */
09: private static final long serialVersionUID = 2351884252990815335L;
10:
11: /** The cause for this exception. */
12: private Throwable _cause;
13:
14: public CastorIllegalStateException() {
15: super ();
16: }
17:
18: public CastorIllegalStateException(final String message) {
19: super (message);
20: }
21:
22: public CastorIllegalStateException(final Throwable cause) {
23: super ();
24: _cause = cause;
25: }
26:
27: public CastorIllegalStateException(final String message,
28: final Throwable cause) {
29: super (message);
30: _cause = cause;
31: }
32:
33: /**
34: * Match the JDK 1.4 Throwable version of getCause() on JDK<1.4 systems.
35: *
36: * @return The throwable cause of this exception.
37: */
38: public Throwable getCause() {
39: return _cause;
40: }
41:
42: /**
43: * Print a stack trace to stderr.
44: */
45: public void printStackTrace() {
46: // Print the stack trace for this exception.
47: super .printStackTrace();
48:
49: if (_cause != null) {
50: System.err.print("Caused by: ");
51: _cause.printStackTrace();
52: }
53: }
54:
55: /**
56: * Print a stack trace to the specified PrintStream.
57: *
58: * @param s The PrintStream to print a stack trace to.
59: */
60: public void printStackTrace(final PrintStream s) {
61: // Print the stack trace for this exception.
62: super .printStackTrace(s);
63:
64: if (_cause != null) {
65: s.print("Caused by: ");
66: _cause.printStackTrace(s);
67: }
68: }
69:
70: /**
71: * Print a stack trace to the specified PrintWriter.
72: *
73: * @param w The PrintWriter to print a stack trace to.
74: */
75: public void printStackTrace(final PrintWriter w) {
76: // Print the stack trace for this exception.
77: super .printStackTrace(w);
78:
79: if (_cause != null) {
80: w.print("Caused by: ");
81: _cause.printStackTrace(w);
82: }
83: }
84: }
|