001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the License). You may not use this file except in
005: * compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://glassfish.dev.java.net/public/CDDLv1.0.html or
009: * glassfish/bootstrap/legal/CDDLv1.0.txt.
010: * See the License for the specific language governing
011: * permissions and limitations under the License.
012: *
013: * When distributing Covered Code, include this CDDL
014: * Header Notice in each file and include the License file
015: * at glassfish/bootstrap/legal/CDDLv1.0.txt.
016: * If applicable, add the following below the CDDL Header,
017: * with the fields enclosed by brackets [] replaced by
018: * you own identifying information:
019: * "Portions Copyrighted [year] [name of copyright owner]"
020: *
021: * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
022: */
023:
024: package javax.jms;
025:
026: /**
027: * <P>
028: * This is the root class of all JMS API exceptions.
029: *
030: * <P>
031: * It provides the following information:
032: * <UL>
033: * <LI> A provider-specific string describing the error. This string is the
034: * standard exception message and is available via the <CODE>getMessage</CODE>
035: * method.
036: * <LI> A provider-specific string error code
037: * <LI> A reference to another exception. Often a JMS API exception will be the
038: * result of a lower-level problem. If appropriate, this lower-level exception
039: * can be linked to the JMS API exception.
040: * </UL>
041: *
042: */
043:
044: public class JMSException extends Exception {
045:
046: private static final long serialVersionUID = 1L;
047:
048: /**
049: * Vendor-specific error code.
050: */
051: private String errorCode;
052:
053: /**
054: * <CODE>Exception</CODE> reference.
055: */
056: private Exception linkedException;
057:
058: /**
059: * Constructs a <CODE>JMSException</CODE> with the specified reason and
060: * error code.
061: *
062: * @param reason
063: * a description of the exception
064: * @param errorCode
065: * a string specifying the vendor-specific error code
066: */
067: public JMSException(String reason, String errorCode) {
068: super (reason);
069: this .errorCode = errorCode;
070: linkedException = null;
071: }
072:
073: /**
074: * Constructs a <CODE>JMSException</CODE> with the specified reason and
075: * with the error code defaulting to null.
076: *
077: * @param reason
078: * a description of the exception
079: */
080: public JMSException(String reason) {
081: super (reason);
082: this .errorCode = null;
083: linkedException = null;
084: }
085:
086: /**
087: * Gets the vendor-specific error code.
088: *
089: * @return a string specifying the vendor-specific error code
090: */
091: public String getErrorCode() {
092: return this .errorCode;
093: }
094:
095: /**
096: * Gets the exception linked to this one.
097: *
098: * @return the linked <CODE>Exception</CODE>, null if none
099: */
100: public Exception getLinkedException() {
101: return (linkedException);
102: }
103:
104: /**
105: * Adds a linked <CODE>Exception</CODE>.
106: *
107: * @param ex
108: * the linked <CODE>Exception</CODE>
109: */
110: public synchronized void setLinkedException(Exception ex) {
111: linkedException = ex;
112: }
113: }
|