Path: blob/master/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java
40948 views
/*1* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.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 it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* 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 WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.stream;2627/**28* The base exception for unexpected processing errors. This Exception29* class is used to report well-formedness errors as well as unexpected30* processing conditions.31* @version 1.032* @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.33* @since 1.634*/3536public class XMLStreamException extends Exception {37private static final long serialVersionUID = 2018819321811497362L;3839/**40* The nested exception.41*/42protected Throwable nested;4344/**45* The location of the error.46*/47protected Location location;4849/**50* Default constructor51*/52public XMLStreamException(){53super();54}5556/**57* Construct an exception with the assocated message.58*59* @param msg the message to report60*/61public XMLStreamException(String msg) {62super(msg);63}6465/**66* Construct an exception with the assocated exception67*68* @param th a nested exception69*/70public XMLStreamException(Throwable th) {71super(th);72nested = th;73}7475/**76* Construct an exception with the assocated message and exception77*78* @param th a nested exception79* @param msg the message to report80*/81public XMLStreamException(String msg, Throwable th) {82super(msg, th);83nested = th;84}8586/**87* Construct an exception with the assocated message, exception and location.88*89* @param th a nested exception90* @param msg the message to report91* @param location the location of the error92*/93public XMLStreamException(String msg, Location location, Throwable th) {94super("ParseError at [row,col]:["+location.getLineNumber()+","+95location.getColumnNumber()+"]\n"+96"Message: "+msg);97nested = th;98this.location = location;99}100101/**102* Construct an exception with the assocated message, exception and location.103*104* @param msg the message to report105* @param location the location of the error106*/107public XMLStreamException(String msg,108Location location) {109super("ParseError at [row,col]:["+location.getLineNumber()+","+110location.getColumnNumber()+"]\n"+111"Message: "+msg);112this.location = location;113}114115116/**117* Gets the nested exception.118*119* @return Nested exception120*/121public Throwable getNestedException() {122return nested;123}124125/**126* Gets the location of the exception127*128* @return the location of the exception, may be null if none is available129*/130public Location getLocation() {131return location;132}133134}135136137