001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package java.rmi;
028:
029: /**
030: * A <code>RemoteException</code> is the common superclass for a number of
031: * communication-related exceptions that may occur during the execution of a
032: * remote method call. Each method of a remote interface, an interface that
033: * extends <code>java.rmi.Remote</code>, MUST list
034: * <code>RemoteException</code> in its <code>throws</code> clause.
035: *
036: * @version 1.21, 02/21/02
037: * @since JDK1.1
038: */
039: public class RemoteException extends java.io.IOException {
040:
041: /** Indicate compatibility with JDK 1.1.x version of class. */
042: private static final long serialVersionUID = -5148567311918794206L;
043:
044: /**
045: * Nested exception to hold wrapped remote exception.
046: *
047: * @since JDK1.1
048: */
049: public Throwable detail;
050:
051: /**
052: * Constructs a <code>RemoteException</code> with no specified
053: * detail message.
054: * @since JDK1.1
055: */
056: public RemoteException() {
057: }
058:
059: /**
060: * Constructs a <code>RemoteException</code> with the specified
061: * detail message.
062: *
063: * @param s the detail message
064: * @since JDK1.1
065: */
066: public RemoteException(String s) {
067: super (s);
068: }
069:
070: /**
071: * Constructs a <code>RemoteException</code> with the specified
072: * detail message and nested exception.
073: *
074: * @param s the detail message
075: * @param ex the nested exception
076: * @since JDK1.1
077: */
078: public RemoteException(String s, Throwable ex) {
079: super (s);
080: detail = ex;
081: }
082:
083: /**
084: * Returns the detail message, including the message from the nested
085: * exception if there is one.
086: * @since JDK1.1
087: * @return the message saved when the exception was constructed
088: */
089: public String getMessage() {
090: if (detail == null)
091: return super .getMessage();
092: else
093: return super .getMessage() + "; nested exception is: \n\t"
094: + detail.toString();
095: }
096:
097: /**
098: * Prints the composite message and the embedded stack trace to
099: * the specified stream <code>ps</code>.
100: * @param ps the print stream
101: * @since 1.2
102: public void printStackTrace(java.io.PrintStream ps)
103: {
104: if (detail == null) {
105: super.printStackTrace(ps);
106: } else {
107: synchronized (ps) {
108: ps.println(this);
109: detail.printStackTrace(ps);
110: }
111: }
112: }
113: */
114:
115: /**
116: * Prints the composite message to <code>System.err</code>.
117: * @since 1.2
118: public void printStackTrace()
119: {
120: printStackTrace(System.err);
121: }
122: */
123:
124: /**
125: * Prints the composite message and the embedded stack trace to
126: * the specified print writer <code>pw</code>.
127: * @param pw the print writer
128: * @since 1.2
129: public void printStackTrace(java.io.PrintWriter pw)
130: {
131: if (detail == null) {
132: super.printStackTrace(pw);
133: } else {
134: synchronized (pw) {
135: pw.println(this);
136: detail.printStackTrace(pw);
137: }
138: }
139: }
140: */
141: }
|