001 package javax.xml.stream;
002
003 /**
004 * The base exception for unexpected processing errors. This Exception
005 * class is used to report well-formedness errors as well as unexpected
006 * processing conditions.
007 * @version 1.0
008 * @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
009 * @since 1.6
010 */
011 public class XMLStreamException extends Exception {
012
013 protected Throwable nested;
014 protected Location location;
015
016 /**
017 * Default constructor
018 */
019 public XMLStreamException() {
020 super ();
021 }
022
023 /**
024 * Construct an exception with the assocated message.
025 *
026 * @param msg the message to report
027 */
028 public XMLStreamException(String msg) {
029 super (msg);
030 }
031
032 /**
033 * Construct an exception with the assocated exception
034 *
035 * @param th a nested exception
036 */
037 public XMLStreamException(Throwable th) {
038 super (th);
039 nested = th;
040 }
041
042 /**
043 * Construct an exception with the assocated message and exception
044 *
045 * @param th a nested exception
046 * @param msg the message to report
047 */
048 public XMLStreamException(String msg, Throwable th) {
049 super (msg, th);
050 nested = th;
051 }
052
053 /**
054 * Construct an exception with the assocated message, exception and location.
055 *
056 * @param th a nested exception
057 * @param msg the message to report
058 * @param location the location of the error
059 */
060 public XMLStreamException(String msg, Location location,
061 Throwable th) {
062 super ("ParseError at [row,col]:[" + location.getLineNumber()
063 + "," + location.getColumnNumber() + "]\n"
064 + "Message: " + msg);
065 nested = th;
066 this .location = location;
067 }
068
069 /**
070 * Construct an exception with the assocated message, exception and location.
071 *
072 * @param msg the message to report
073 * @param location the location of the error
074 */
075 public XMLStreamException(String msg, Location location) {
076 super ("ParseError at [row,col]:[" + location.getLineNumber()
077 + "," + location.getColumnNumber() + "]\n"
078 + "Message: " + msg);
079 this .location = location;
080 }
081
082 /**
083 * Gets the nested exception.
084 *
085 * @return Nested exception
086 */
087 public Throwable getNestedException() {
088 return nested;
089 }
090
091 /**
092 * Gets the location of the exception
093 *
094 * @return the location of the exception, may be null if none is available
095 */
096 public Location getLocation() {
097 return location;
098 }
099
100 }
|