Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBException.java
38890 views
/*1* Copyright (c) 2003, 2013, 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.bind;2627import java.io.PrintWriter;2829/**30* This is the root exception class for all JAXB exceptions.31*32* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul>33* @see JAXBContext34* @see Marshaller35* @see Unmarshaller36* @since JAXB1.037*/38public class JAXBException extends Exception {3940/**41* Vendor specific error code42*43*/44private String errorCode;4546/**47* Exception reference48*49*/50private volatile Throwable linkedException;5152static final long serialVersionUID = -5621384651494307979L;5354/**55* Construct a JAXBException with the specified detail message. The56* errorCode and linkedException will default to null.57*58* @param message a description of the exception59*/60public JAXBException(String message) {61this( message, null, null );62}6364/**65* Construct a JAXBException with the specified detail message and vendor66* specific errorCode. The linkedException will default to null.67*68* @param message a description of the exception69* @param errorCode a string specifying the vendor specific error code70*/71public JAXBException(String message, String errorCode) {72this( message, errorCode, null );73}7475/**76* Construct a JAXBException with a linkedException. The detail message and77* vendor specific errorCode will default to null.78*79* @param exception the linked exception80*/81public JAXBException(Throwable exception) {82this( null, null, exception );83}8485/**86* Construct a JAXBException with the specified detail message and87* linkedException. The errorCode will default to null.88*89* @param message a description of the exception90* @param exception the linked exception91*/92public JAXBException(String message, Throwable exception) {93this( message, null, exception );94}9596/**97* Construct a JAXBException with the specified detail message, vendor98* specific errorCode, and linkedException.99*100* @param message a description of the exception101* @param errorCode a string specifying the vendor specific error code102* @param exception the linked exception103*/104public JAXBException(String message, String errorCode, Throwable exception) {105super( message );106this.errorCode = errorCode;107this.linkedException = exception;108}109110/**111* Get the vendor specific error code112*113* @return a string specifying the vendor specific error code114*/115public String getErrorCode() {116return this.errorCode;117}118119/**120* Get the linked exception121*122* @return the linked Exception, null if none exists123*/124public Throwable getLinkedException() {125return linkedException;126}127128/**129* Add a linked Exception.130*131* @param exception the linked Exception (A null value is permitted and132* indicates that the linked exception does not exist or133* is unknown).134*/135public void setLinkedException( Throwable exception ) {136this.linkedException = exception;137}138139/**140* Returns a short description of this JAXBException.141*142*/143public String toString() {144return linkedException == null ?145super.toString() :146super.toString() + "\n - with linked exception:\n[" +147linkedException.toString()+ "]";148}149150/**151* Prints this JAXBException and its stack trace (including the stack trace152* of the linkedException if it is non-null) to the PrintStream.153*154* @param s PrintStream to use for output155*/156public void printStackTrace( java.io.PrintStream s ) {157super.printStackTrace(s);158}159160/**161* Prints this JAXBException and its stack trace (including the stack trace162* of the linkedException if it is non-null) to <tt>System.err</tt>.163*164*/165public void printStackTrace() {166super.printStackTrace();167}168169/**170* Prints this JAXBException and its stack trace (including the stack trace171* of the linkedException if it is non-null) to the PrintWriter.172*173* @param s PrintWriter to use for output174*/175public void printStackTrace(PrintWriter s) {176super.printStackTrace(s);177}178179@Override180public Throwable getCause() {181return linkedException;182}183}184185186