2
* Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
4
* This software is open source.
5
* See the bottom of this file for the licence.
10
import java.io.PrintStream;
11
import java.io.PrintWriter;
15
* <code>DocumentException</code> is a nested Exception which may be thrown
16
* during the processing of a DOM4J document.
19
* @author <a href="mailto:james.strachan@metastuff.com">James Strachan </a>
20
* @version $Revision: 1.7 $
22
public class DocumentException extends Exception {
23
/** A wrapped <code>Throwable</code> */
24
private Throwable nestedException;
26
public DocumentException() {
27
super("Error occurred in DOM4J application.");
30
public DocumentException(String message) {
34
public DocumentException(Throwable nestedException) {
35
super(nestedException.getMessage());
36
this.nestedException = nestedException;
39
public DocumentException(String message, Throwable nestedException) {
41
this.nestedException = nestedException;
44
public Throwable getNestedException() {
45
return nestedException;
48
// on JDK 1.4 and above this helps exception chaining
49
public Throwable getCause() {
50
return nestedException;
53
public String getMessage() {
54
if (nestedException != null) {
55
return super.getMessage() + " Nested exception: "
56
+ nestedException.getMessage();
58
return super.getMessage();
62
public void printStackTrace() {
63
super.printStackTrace();
65
if (nestedException != null) {
66
System.err.print("Nested exception: ");
67
nestedException.printStackTrace();
71
public void printStackTrace(PrintStream out) {
72
super.printStackTrace(out);
74
if (nestedException != null) {
75
out.println("Nested exception: ");
76
nestedException.printStackTrace(out);
80
public void printStackTrace(PrintWriter writer) {
81
super.printStackTrace(writer);
83
if (nestedException != null) {
84
writer.println("Nested exception: ");
85
nestedException.printStackTrace(writer);
91
* Redistribution and use of this software and associated documentation
92
* ("Software"), with or without modification, are permitted provided that the
93
* following conditions are met:
95
* 1. Redistributions of source code must retain copyright statements and
96
* notices. Redistributions must also contain a copy of this document.
98
* 2. Redistributions in binary form must reproduce the above copyright notice,
99
* this list of conditions and the following disclaimer in the documentation
100
* and/or other materials provided with the distribution.
102
* 3. The name "DOM4J" must not be used to endorse or promote products derived
103
* from this Software without prior written permission of MetaStuff, Ltd. For
104
* written permission, please contact dom4j-info@metastuff.com.
106
* 4. Products derived from this Software may not be called "DOM4J" nor may
107
* "DOM4J" appear in their names without prior written permission of MetaStuff,
108
* Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
110
* 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
112
* THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
113
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
114
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
115
* ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
116
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
117
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
118
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
119
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
120
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
121
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
122
* POSSIBILITY OF SUCH DAMAGE.
124
* Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.