12005
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
|
23 |
*/
|
|
24 |
|
|
25 |
/*
|
|
26 |
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
|
27 |
*/
|
|
28 |
|
|
29 |
package javax.xml.stream;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* The base exception for unexpected processing errors. This Exception
|
|
33 |
* class is used to report well-formedness errors as well as unexpected
|
|
34 |
* processing conditions.
|
|
35 |
* @version 1.0
|
|
36 |
* @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
|
37 |
* @since 1.6
|
|
38 |
*/
|
|
39 |
|
|
40 |
public class XMLStreamException extends Exception {
|
|
41 |
|
|
42 |
protected Throwable nested;
|
|
43 |
protected Location location;
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Default constructor
|
|
47 |
*/
|
|
48 |
public XMLStreamException(){
|
|
49 |
super();
|
|
50 |
}
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Construct an exception with the assocated message.
|
|
54 |
*
|
|
55 |
* @param msg the message to report
|
|
56 |
*/
|
|
57 |
public XMLStreamException(String msg) {
|
|
58 |
super(msg);
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Construct an exception with the assocated exception
|
|
63 |
*
|
|
64 |
* @param th a nested exception
|
|
65 |
*/
|
|
66 |
public XMLStreamException(Throwable th) {
|
|
67 |
super(th);
|
|
68 |
nested = th;
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Construct an exception with the assocated message and exception
|
|
73 |
*
|
|
74 |
* @param th a nested exception
|
|
75 |
* @param msg the message to report
|
|
76 |
*/
|
|
77 |
public XMLStreamException(String msg, Throwable th) {
|
|
78 |
super(msg, th);
|
|
79 |
nested = th;
|
|
80 |
}
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Construct an exception with the assocated message, exception and location.
|
|
84 |
*
|
|
85 |
* @param th a nested exception
|
|
86 |
* @param msg the message to report
|
|
87 |
* @param location the location of the error
|
|
88 |
*/
|
|
89 |
public XMLStreamException(String msg, Location location, Throwable th) {
|
|
90 |
super("ParseError at [row,col]:["+location.getLineNumber()+","+
|
|
91 |
location.getColumnNumber()+"]\n"+
|
|
92 |
"Message: "+msg);
|
|
93 |
nested = th;
|
|
94 |
this.location = location;
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
* Construct an exception with the assocated message, exception and location.
|
|
99 |
*
|
|
100 |
* @param msg the message to report
|
|
101 |
* @param location the location of the error
|
|
102 |
*/
|
|
103 |
public XMLStreamException(String msg,
|
|
104 |
Location location) {
|
|
105 |
super("ParseError at [row,col]:["+location.getLineNumber()+","+
|
|
106 |
location.getColumnNumber()+"]\n"+
|
|
107 |
"Message: "+msg);
|
|
108 |
this.location = location;
|
|
109 |
}
|
|
110 |
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Gets the nested exception.
|
|
114 |
*
|
|
115 |
* @return Nested exception
|
|
116 |
*/
|
|
117 |
public Throwable getNestedException() {
|
|
118 |
return nested;
|
|
119 |
}
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Gets the location of the exception
|
|
123 |
*
|
|
124 |
* @return the location of the exception, may be null if none is available
|
|
125 |
*/
|
|
126 |
public Location getLocation() {
|
|
127 |
return location;
|
|
128 |
}
|
|
129 |
|
|
130 |
}
|