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