1 /*
2 * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
77 *
78 * @param message The error or warning message.
79 */
80 public SAXException (String message) {
81 super(message);
82 this.exception = null;
83 }
84
85
86 /**
87 * Create a new SAXException wrapping an existing exception.
88 *
89 * <p>The existing exception will be embedded in the new
90 * one, and its message will become the default message for
91 * the SAXException.</p>
92 *
93 * @param e The exception to be wrapped in a SAXException.
94 */
95 public SAXException (Exception e)
96 {
97 super();
98 this.exception = e;
99 }
100
101
102 /**
103 * Create a new SAXException from an existing exception.
104 *
105 * <p>The existing exception will be embedded in the new
106 * one, but the new exception will have its own message.</p>
107 *
108 * @param message The detail message.
109 * @param e The exception to be wrapped in a SAXException.
110 */
111 public SAXException (String message, Exception e)
112 {
113 super(message);
114 this.exception = e;
115 }
116
117
135 }
136 }
137
138
139 /**
140 * Return the embedded exception, if any.
141 *
142 * @return The embedded exception, or null if there is none.
143 */
144 public Exception getException ()
145 {
146 return exception;
147 }
148
149 /**
150 * Return the cause of the exception
151 *
152 * @return Return the cause of the exception
153 */
154 public Throwable getCause() {
155 return exception;
156 }
157
158 /**
159 * Override toString to pick up any embedded exception.
160 *
161 * @return A string representation of this exception.
162 */
163 public String toString ()
164 {
165 if (exception != null) {
166 return super.toString() + "\n" + exception.toString();
167 } else {
168 return super.toString();
169 }
170 }
171
172
173
174 //////////////////////////////////////////////////////////////////////
175 // Internal state.
|
1 /*
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
77 *
78 * @param message The error or warning message.
79 */
80 public SAXException (String message) {
81 super(message);
82 this.exception = null;
83 }
84
85
86 /**
87 * Create a new SAXException wrapping an existing exception.
88 *
89 * <p>The existing exception will be embedded in the new
90 * one, and its message will become the default message for
91 * the SAXException.</p>
92 *
93 * @param e The exception to be wrapped in a SAXException.
94 */
95 public SAXException (Exception e)
96 {
97 super(e);
98 this.exception = e;
99 }
100
101
102 /**
103 * Create a new SAXException from an existing exception.
104 *
105 * <p>The existing exception will be embedded in the new
106 * one, but the new exception will have its own message.</p>
107 *
108 * @param message The detail message.
109 * @param e The exception to be wrapped in a SAXException.
110 */
111 public SAXException (String message, Exception e)
112 {
113 super(message);
114 this.exception = e;
115 }
116
117
135 }
136 }
137
138
139 /**
140 * Return the embedded exception, if any.
141 *
142 * @return The embedded exception, or null if there is none.
143 */
144 public Exception getException ()
145 {
146 return exception;
147 }
148
149 /**
150 * Return the cause of the exception
151 *
152 * @return Return the cause of the exception
153 */
154 public Throwable getCause() {
155 return super.getCause();
156 }
157
158 /**
159 * Override toString to pick up any embedded exception.
160 *
161 * @return A string representation of this exception.
162 */
163 public String toString ()
164 {
165 if (exception != null) {
166 return super.toString() + "\n" + exception.toString();
167 } else {
168 return super.toString();
169 }
170 }
171
172
173
174 //////////////////////////////////////////////////////////////////////
175 // Internal state.
|