1. /*
  2. * @(#)ActivationException.java 1.22 03/01/23
  3. *
  4. * Copyright 2003 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. * @author Ann Wollrath
  19. * @version 1.22, 01/23/03
  20. * @since 1.2
  21. */
  22. public class ActivationException extends Exception {
  23. /**
  24. * Nested Exception to hold wrapped remote exceptions.
  25. *
  26. * <p>This field predates the general-purpose exception chaining facility.
  27. * The {@link Throwable#getCause()} method is now the preferred means of
  28. * obtaining this information.
  29. *
  30. * @serial
  31. */
  32. public Throwable detail;
  33. /** indicate compatibility with the Java 2 SDK v1.2 version of class */
  34. private static final long serialVersionUID = -4320118837291406071L;
  35. /**
  36. * Constructs an <code>ActivationException</code> with no specified
  37. * detail message.
  38. * @since 1.2
  39. */
  40. public ActivationException() {
  41. initCause(null); // Disallow subsequent initCause
  42. }
  43. /**
  44. * Constructs an <code>ActivationException</code> with detail
  45. * message, <code>s</code>.
  46. * @param s the detail message
  47. * @since 1.2
  48. */
  49. public ActivationException(String s) {
  50. super(s);
  51. initCause(null); // Disallow subsequent initCause
  52. }
  53. /**
  54. * Constructs an <code>ActivationException</code> with detail message,
  55. * <code>s</code>, and detail exception <code>ex</code>.
  56. *
  57. * @param s detail message
  58. * @param ex detail exception
  59. * @since 1.2
  60. */
  61. public ActivationException(String s, Throwable ex) {
  62. super(s);
  63. initCause(null); // Disallow subsequent initCause
  64. detail = ex;
  65. }
  66. /**
  67. * Returns the detail message, including the message from the detail
  68. * exception if there is one.
  69. *
  70. * @return the detail message, including detail exception message if any
  71. * @since 1.2
  72. */
  73. public String getMessage() {
  74. if (detail == null)
  75. return super.getMessage();
  76. else
  77. return super.getMessage() +
  78. "; nested exception is: \n\t" +
  79. detail.toString();
  80. }
  81. /**
  82. * Returns the detail exception (the <i>cause</i>).
  83. *
  84. * @return the detail exception, which may be <tt>null</tt>.
  85. * @since 1.4
  86. */
  87. public Throwable getCause() {
  88. return detail;
  89. }
  90. }