1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.jms;
  6. /**
  7. * <P>This is the root class of all JMS API exceptions.
  8. *
  9. * <P>It provides the following information:
  10. * <UL>
  11. * <LI> A provider-specific string describing the error. This string is
  12. * the standard exception message and is available via the
  13. * <CODE>getMessage</CODE> method.
  14. * <LI> A provider-specific string error code
  15. * <LI> A reference to another exception. Often a JMS API exception will
  16. * be the result of a lower-level problem. If appropriate, this
  17. * lower-level exception can be linked to the JMS API exception.
  18. * </UL>
  19. * @version 1.0 - 5 Oct 1998
  20. * @author Mark Hapner
  21. * @author Rich Burridge
  22. **/
  23. public class JMSException extends Exception {
  24. /** Vendor-specific error code.
  25. **/
  26. private String errorCode;
  27. /** <CODE>Exception</CODE> reference.
  28. **/
  29. private Exception linkedException;
  30. /** Constructs a <CODE>JMSException</CODE> with the specified reason and
  31. * error code.
  32. *
  33. * @param reason a description of the exception
  34. * @param errorCode a string specifying the vendor-specific
  35. * error code
  36. **/
  37. public
  38. JMSException(String reason, String errorCode) {
  39. super(reason);
  40. this.errorCode = errorCode;
  41. linkedException = null;
  42. }
  43. /** Constructs a <CODE>JMSException</CODE> with the specified reason and with
  44. * the error code defaulting to null.
  45. *
  46. * @param reason a description of the exception
  47. **/
  48. public
  49. JMSException(String reason) {
  50. super(reason);
  51. this.errorCode = null;
  52. linkedException = null;
  53. }
  54. /** Gets the vendor-specific error code.
  55. * @return a string specifying the vendor-specific
  56. * error code
  57. **/
  58. public
  59. String getErrorCode() {
  60. return this.errorCode;
  61. }
  62. /**
  63. * Gets the exception linked to this one.
  64. *
  65. * @return the linked <CODE>Exception</CODE>, null if none
  66. **/
  67. public
  68. Exception getLinkedException() {
  69. return (linkedException);
  70. }
  71. /**
  72. * Adds a linked <CODE>Exception</CODE>.
  73. *
  74. * @param ex the linked <CODE>Exception</CODE>
  75. **/
  76. public
  77. synchronized void setLinkedException(Exception ex) {
  78. linkedException = ex;
  79. }
  80. }