1. /*
  2. * @(#)ActivationException.java 1.15 01/11/29
  3. *
  4. * Copyright 2002 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. * @author Ann Wollrath
  12. * @version 1.15, 11/29/01
  13. * @since JDK1.2
  14. */
  15. public class ActivationException extends Exception {
  16. /**
  17. * Nested Exception to hold wrapped remote exceptions.
  18. *
  19. * @serial
  20. */
  21. public Throwable detail;
  22. /** indicate compatibility with JDK 1.2 version of class */
  23. private static final long serialVersionUID = -4320118837291406071L;
  24. /**
  25. * Constructs an <code>ActivationException</code> with no specified
  26. * detail message.
  27. * @since JDK1.2
  28. */
  29. public ActivationException() {
  30. super();
  31. }
  32. /**
  33. * Constructs an <code>ActivationException</code> with detail
  34. * message, <code>s</code>.
  35. * @param s the detail message
  36. * @since JDK1.2
  37. */
  38. public ActivationException(String s) {
  39. super(s);
  40. }
  41. /**
  42. * Constructs an <code>ActivationException</code> with detail message,
  43. * <code>s</code>, and detail exception <code>ex</code>.
  44. *
  45. * @param s detail message
  46. * @param ex detail exception
  47. * @since JDK1.2
  48. */
  49. public ActivationException(String s, Throwable ex) {
  50. super(s);
  51. detail = ex;
  52. }
  53. /**
  54. * Produces the message, include the message from the nested
  55. * exception if there is one.
  56. * @return the message
  57. * @since JDK1.2
  58. */
  59. public String getMessage() {
  60. if (detail == null)
  61. return super.getMessage();
  62. else
  63. return super.getMessage() +
  64. "; nested exception is: \n\t" +
  65. detail.toString();
  66. }
  67. /**
  68. * Prints the composite message and the embedded stack trace to
  69. * the specified stream <code>ps</code>.
  70. * @param ps the print stream
  71. * @since JDK1.2
  72. */
  73. public void printStackTrace(java.io.PrintStream ps) {
  74. if (detail == null) {
  75. super.printStackTrace(ps);
  76. } else {
  77. synchronized(ps) {
  78. ps.println(this);
  79. detail.printStackTrace(ps);
  80. }
  81. }
  82. }
  83. /**
  84. * Prints the composite message to <code>System.err</code>.
  85. * @since JDK1.2
  86. */
  87. public void printStackTrace() {
  88. printStackTrace(System.err);
  89. }
  90. /**
  91. * Prints the composite message and the embedded stack trace to
  92. * the specified print writer <code>pw</code>
  93. * @param pw the print writer
  94. * @since JDK1.2
  95. */
  96. public void printStackTrace(java.io.PrintWriter pw)
  97. {
  98. if (detail == null) {
  99. super.printStackTrace(pw);
  100. } else {
  101. synchronized(pw) {
  102. pw.println(this);
  103. detail.printStackTrace(pw);
  104. }
  105. }
  106. }
  107. }