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