Save This Page
Home » jboss-javaee-sources » javax » jms » [javadoc | source]
    1   /*
    2    * JBoss, Home of Professional Open Source
    3    * Copyright 2005, JBoss Inc., and individual contributors as indicated
    4    * by the @authors tag. See the copyright.txt in the distribution for a
    5    * full listing of individual contributors.
    6    *
    7    * This is free software; you can redistribute it and/or modify it
    8    * under the terms of the GNU Lesser General Public License as
    9    * 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   {
   41      private static final long serialVersionUID = 8951994251593378324L;
   42   
   43      /** Vendor-specific error code.
   44       **/
   45      private String errorCode;
   46   
   47      /** <CODE>Exception</CODE> reference.
   48       **/
   49      private Exception linkedException;
   50   
   51      /** Constructs a <CODE>JMSException</CODE> with the specified reason and 
   52       *  error code.
   53       *
   54       *  @param  reason        a description of the exception
   55       *  @param  errorCode     a string specifying the vendor-specific
   56       *                        error code
   57       **/
   58      public JMSException(String reason, String errorCode)
   59      {
   60         super(reason);
   61         this.errorCode = errorCode;
   62         linkedException = null;
   63      }
   64   
   65      /** Constructs a <CODE>JMSException</CODE> with the specified reason and with
   66       *  the error code defaulting to null.
   67       *
   68       *  @param  reason        a description of the exception
   69       **/
   70      public JMSException(String reason)
   71      {
   72         super(reason);
   73         this.errorCode = null;
   74         linkedException = null;
   75      }
   76   
   77      /** Gets the vendor-specific error code.
   78       *  @return   a string specifying the vendor-specific
   79       *                        error code
   80       **/
   81      public String getErrorCode()
   82      {
   83         return this.errorCode;
   84      }
   85   
   86      /**
   87       * Gets the exception linked to this one.
   88       *
   89       * @return the linked <CODE>Exception</CODE>, null if none
   90       **/
   91      public Exception getLinkedException()
   92      {
   93         return (linkedException);
   94      }
   95   
   96      /**
   97       * Adds a linked <CODE>Exception</CODE>.
   98       *
   99       * @param ex       the linked <CODE>Exception</CODE>
  100       **/
  101      public synchronized void setLinkedException(Exception ex)
  102      {
  103         linkedException = ex;
  104      }
  105   }

Save This Page
Home » jboss-javaee-sources » javax » jms » [javadoc | source]