1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package javax.portlet;
22
23
24
25 /***
26 * The <CODE>PortletException</CODE> class defines a general exception
27 * that a portlet can throw when it is unable to perform its operation
28 * successfully.
29 */
30
31 public class PortletException extends java.lang.Exception
32 {
33
34
35 private Throwable _cause;
36
37
38 /***
39 * Constructs a new portlet exception.
40 */
41
42 public PortletException ()
43 {
44 super();
45 }
46
47 /***
48 * Constructs a new portlet exception with the given text. The
49 * portlet container may use the text write it to a log.
50 *
51 * @param text
52 * the exception text
53 */
54
55 public PortletException (String text)
56 {
57 super (text);
58 }
59
60 /***
61 * Constructs a new portlet exception when the portlet needs to do
62 * the following:
63 * <ul>
64 * <li>throw an exception
65 * <li>include the "root cause" exception
66 * <li>include a description message
67 * </ul>
68 *
69 * @param text
70 * the exception text
71 * @param cause
72 * the root cause
73 */
74
75 public PortletException (String text, Throwable cause)
76 {
77 super(text);
78 _cause = cause;
79
80 }
81
82 /***
83 * Constructs a new portlet exception when the portlet needs to throw an
84 * exception. The exception's message is based on the localized message
85 * of the underlying exception.
86 *
87 * @param cause
88 * the root cause
89 */
90
91 public PortletException (Throwable cause)
92 {
93 _cause = cause;
94
95 }
96
97 /***
98 * Prints the stack trace of this exception to the standard error stream.
99 */
100 public void printStackTrace()
101 {
102 this.printStackTrace(System.err);
103 }
104
105 /***
106 * Prints the stack trace of this exception to the specified print stream.
107 *
108 * @param out the <code>PrintStream</code> to be used for output
109 */
110 public void printStackTrace(java.io.PrintStream out)
111 {
112 this.printStackTrace(new java.io.PrintWriter(out, true));
113 }
114
115 /***
116 * Prints the stack trace of this exception to the specified print writer.
117 *
118 * @param out the <code>PrintWriter</code> to be used for output
119 */
120 public void printStackTrace(java.io.PrintWriter out)
121 {
122 super.printStackTrace(out);
123
124 if( getCause () != null ) {
125 out.println();
126 out.print("Nested Exception is ");
127 getCause ().printStackTrace(out);
128 }
129
130
131
132
133
134
135
136
137
138
139
140 }
141
142 /***
143 * Returns the cause of this throwable or <code>null</code> if the
144 * cause is nonexistent or unknown. (The cause is the throwable that
145 * caused this throwable to get thrown.)
146 *
147 * <p>This implementation returns the cause that was supplied via one of
148 * the constructors requiring a <tt>Throwable</tt>.
149 *
150 * @return the cause of this throwable or <code>null</code> if the
151 * cause is nonexistent or unknown.
152 */
153 public Throwable getCause() {
154 return (_cause!=null ? _cause : null);
155 }
156
157 }