1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.resource;
  6. /**
  7. * This is the root interface of the exception hierarchy defined
  8. * for the Connector architecture.
  9. *
  10. * The ResourceException provides the following information:
  11. * <UL>
  12. * <LI> A resource adapter vendor specific string describing the error.
  13. * This string is a standard Java exception message and is available
  14. * through getMessage() method.
  15. * <LI> resource adapter vendor specific error code
  16. * <LI> reference to another exception. Often a resource exception
  17. * will be result of a lower level problem. If appropriate, this
  18. * lower level exception can be linked to the ResourceException.
  19. * </UL>
  20. * @version 0.7
  21. * @author Rahul Sharma
  22. */
  23. public class ResourceException extends java.lang.Exception {
  24. /** Vendor specific error code
  25. **/
  26. private String errorCode;
  27. /** reference to another exception
  28. **/
  29. private Exception linkedException;
  30. /**
  31. * Create a ResourceException.
  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. ResourceException(String reason, String errorCode) {
  39. super(reason);
  40. this.errorCode = errorCode;
  41. this.linkedException = null;
  42. }
  43. /**
  44. * Create a ResourceException with reason.
  45. *
  46. * @param reason a description of the exception
  47. **/
  48. public
  49. ResourceException(String reason) {
  50. super(reason);
  51. this.errorCode = null;
  52. this.linkedException = null;
  53. }
  54. /** Get the vendor specific error code
  55. * @return a string specifying the vendor specific error code
  56. **/
  57. public
  58. String getErrorCode() {
  59. return this.errorCode;
  60. }
  61. /**
  62. * Get the exception linked to this ResourceException
  63. *
  64. * @return linked Exception, null if none
  65. **/
  66. public
  67. Exception getLinkedException() {
  68. return (linkedException);
  69. }
  70. /**
  71. * Add a linked Exception to this ResourceException.
  72. *
  73. * @param ex linked Exception
  74. **/
  75. public
  76. void setLinkedException(Exception ex) {
  77. linkedException = ex;
  78. }
  79. }