1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.xframe.ex;
22
23 import java.io.PrintStream;
24 import java.io.PrintWriter;
25
26 /***
27 * Class from which all xframe exceptions should inherit.
28 * Allows recording of nested exceptions.
29 *
30 * @author <a href="mailto:kriede@users.sourceforge.net">Kurt Riede</a>
31 */
32 public class CascadingException extends Exception {
33
34 /*** The Throwable that caused this exception to be thrown. */
35 private final Throwable cause;
36
37
38
39
40
41
42 /***
43 * Construct a new <code>CascadingException</code> instance.
44 *
45 * @param message The detail message for this exception.
46 */
47 public CascadingException(final String message) {
48 this(message, null);
49 }
50
51 /***
52 * Construct a new <code>CascadingException</code> instance.
53 *
54 * @param message The detail message for this exception.
55 * @param throwable the root cause of the exception
56 */
57 public CascadingException(final String message, final Throwable throwable) {
58 super(message);
59 cause = throwable;
60 }
61
62 /***
63 * Construct a new <code>CascadingException</code> instance.
64 *
65 * @param throwable the root cause of the exception
66 */
67 public CascadingException(final Throwable throwable) {
68 super(throwable.getMessage());
69 cause = throwable;
70 }
71
72
73
74
75
76
77 /***
78 * Retrieve root cause of the exception.
79 *
80 * @return the root cause
81 */
82 public final Throwable getCause() {
83 return cause;
84 }
85
86
87
88
89
90
91 /***
92 * Prints this <code>Throwable</code> and its backtrace to the
93 * standard error stream.
94 *
95 * @see java.lang.Throwable#printStackTrace()
96 */
97 public final void printStackTrace() {
98 super.printStackTrace();
99 }
100
101 /***
102 * Prints this <code>Throwable</code> and its backtrace to the
103 * specified print stream.
104 *
105 * @param s <code>PrintStream</code> to use for output
106 *
107 * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
108 */
109 public final void printStackTrace(final PrintStream s) {
110 super.printStackTrace(s);
111 }
112
113 /***
114 * Prints this <code>Throwable</code> and its backtrace to the specified
115 * print writer.
116 *
117 * @param w <code>PrintWriter</code> to use for output
118 *
119 * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
120 */
121 public final void printStackTrace(final PrintWriter w) {
122 super.printStackTrace(w);
123 }
124 }