1. /*
  2. * @(#)ActivationException.java 1.24 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.rmi.activation;
  8. /**
  9. * General exception used by the activation interfaces.
  10. *
  11. * <p>As of release 1.4, this exception has been retrofitted to conform to
  12. * the general purpose exception-chaining mechanism. The "detail exception"
  13. * that may be provided at construction time and accessed via the public
  14. * {@link #detail} field is now known as the <i>cause</i>, and may be
  15. * accessed via the {@link Throwable#getCause()} method, as well as
  16. * the aforementioned "legacy field."
  17. *
  18. * <p>Invoking the method {@link Throwable#initCause(Throwable)} on an
  19. * instance of <code>ActivationException</code> always throws {@link
  20. * IllegalStateException}.
  21. *
  22. * @author Ann Wollrath
  23. * @version 1.24, 12/19/03
  24. * @since 1.2
  25. */
  26. public class ActivationException extends Exception {
  27. /**
  28. * The cause of the activation exception.
  29. *
  30. * <p>This field predates the general-purpose exception chaining facility.
  31. * The {@link Throwable#getCause()} method is now the preferred means of
  32. * obtaining this information.
  33. *
  34. * @serial
  35. */
  36. public Throwable detail;
  37. /** indicate compatibility with the Java 2 SDK v1.2 version of class */
  38. private static final long serialVersionUID = -4320118837291406071L;
  39. /**
  40. * Constructs an <code>ActivationException</code>.
  41. */
  42. public ActivationException() {
  43. initCause(null); // Disallow subsequent initCause
  44. }
  45. /**
  46. * Constructs an <code>ActivationException</code> with the specified
  47. * detail message.
  48. *
  49. * @param s the detail message
  50. */
  51. public ActivationException(String s) {
  52. super(s);
  53. initCause(null); // Disallow subsequent initCause
  54. }
  55. /**
  56. * Constructs an <code>ActivationException</code> with the specified
  57. * detail message and cause. This constructor sets the {@link #detail}
  58. * field to the specified <code>Throwable</code>.
  59. *
  60. * @param s the detail message
  61. * @param cause the cause
  62. */
  63. public ActivationException(String s, Throwable cause) {
  64. super(s);
  65. initCause(null); // Disallow subsequent initCause
  66. detail = cause;
  67. }
  68. /**
  69. * Returns the detail message, including the message from the cause, if
  70. * any, of this exception.
  71. *
  72. * @return the detail message
  73. */
  74. public String getMessage() {
  75. if (detail == null)
  76. return super.getMessage();
  77. else
  78. return super.getMessage() +
  79. "; nested exception is: \n\t" +
  80. detail.toString();
  81. }
  82. /**
  83. * Returns the cause of this exception. This method returns the value
  84. * of the {@link #detail} field.
  85. *
  86. * @return the cause, which may be <tt>null</tt>.
  87. * @since 1.4
  88. */
  89. public Throwable getCause() {
  90. return detail;
  91. }
  92. }