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