01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package javax.jms;
23:
24: /**
25: * <P>This is the root class of all JMS API exceptions.
26: *
27: * <P>It provides the following information:
28: * <UL>
29: * <LI> A provider-specific string describing the error. This string is
30: * the standard exception message and is available via the
31: * <CODE>getMessage</CODE> method.
32: * <LI> A provider-specific string error code
33: * <LI> A reference to another exception. Often a JMS API exception will
34: * be the result of a lower-level problem. If appropriate, this
35: * lower-level exception can be linked to the JMS API exception.
36: * </UL>
37: **/
38:
39: public class JMSException extends Exception {
40: private static final long serialVersionUID = 8951994251593378324L;
41:
42: /** Vendor-specific error code.
43: **/
44: private String errorCode;
45:
46: /** <CODE>Exception</CODE> reference.
47: **/
48: private Exception linkedException;
49:
50: /** Constructs a <CODE>JMSException</CODE> with the specified reason and
51: * error code.
52: *
53: * @param reason a description of the exception
54: * @param errorCode a string specifying the vendor-specific
55: * error code
56: **/
57: public JMSException(String reason, String errorCode) {
58: super (reason);
59: this .errorCode = errorCode;
60: linkedException = null;
61: }
62:
63: /** Constructs a <CODE>JMSException</CODE> with the specified reason and with
64: * the error code defaulting to null.
65: *
66: * @param reason a description of the exception
67: **/
68: public JMSException(String reason) {
69: super (reason);
70: this .errorCode = null;
71: linkedException = null;
72: }
73:
74: /** Gets the vendor-specific error code.
75: * @return a string specifying the vendor-specific
76: * error code
77: **/
78: public String getErrorCode() {
79: return this .errorCode;
80: }
81:
82: /**
83: * Gets the exception linked to this one.
84: *
85: * @return the linked <CODE>Exception</CODE>, null if none
86: **/
87: public Exception getLinkedException() {
88: return (linkedException);
89: }
90:
91: /**
92: * Adds a linked <CODE>Exception</CODE>.
93: *
94: * @param ex the linked <CODE>Exception</CODE>
95: **/
96: public synchronized void setLinkedException(Exception ex) {
97: linkedException = ex;
98: }
99: }
|