KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > mop > MOPException


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.core.mop;
32
33 /**
34 */

35 public class MOPException extends Exception JavaDoc {
36
37   public Throwable JavaDoc detail;
38  
39   /**
40   * Constructs a <code>ProActiveException</code> with no specified
41   * detail message.
42   */

43   public MOPException() {}
44
45   /**
46   * Constructs a <code>ProActiveException</code> with the specified detail message.
47   * @param s the detail message
48   */

49   public MOPException(String JavaDoc s) {
50     super(s);
51   }
52
53   /**
54   * Constructs a <code>ProActiveException</code> with the specified
55   * detail message and nested exception.
56   *
57   * @param s the detail message
58   * @param ex the nested exception
59   */

60   public MOPException(String JavaDoc s, Throwable JavaDoc ex) {
61     super(s);
62     detail = ex;
63   }
64
65
66   /**
67   * Constructs a <code>ProActiveException</code> with the specified
68   * detail message and nested exception.
69   *
70   * @param ex the nested exception
71   */

72   public MOPException(Throwable JavaDoc ex) {
73     super();
74     detail = ex;
75   }
76
77
78   public Throwable JavaDoc getTargetException() {
79     return detail;
80   }
81
82   
83   /**
84   * Returns the detail message, including the message from the nested
85   * exception if there is one.
86   */

87   public String JavaDoc getMessage() {
88     if (detail == null)
89       return super.getMessage();
90     else {
91       if (super.getMessage() == null)
92         return detail.getMessage();
93       else return super.getMessage() + "; nested exception is: \n" + detail.toString();
94     }
95   }
96
97   /**
98   * Prints the composite message and the embedded stack trace to
99   * the specified stream <code>ps</code>.
100   * @param ps the print stream
101   */

102   public void printStackTrace(java.io.PrintStream JavaDoc ps) {
103     if (detail == null) {
104       super.printStackTrace(ps);
105     } else {
106       synchronized(ps) {
107         ps.println(getMessage());
108         detail.printStackTrace(ps);
109       }
110     }
111   }
112
113   /**
114   * Prints the composite message to <code>System.err</code>.
115   */

116   public void printStackTrace() {
117     printStackTrace(System.err);
118   }
119
120   /**
121   * Prints the composite message and the embedded stack trace to
122   * the specified print writer <code>pw</code>.
123   * @param pw the print writer
124   */

125   public void printStackTrace(java.io.PrintWriter JavaDoc pw) {
126     if (detail == null) {
127       super.printStackTrace(pw);
128     } else {
129       synchronized(pw) {
130         pw.println(getMessage());
131         detail.printStackTrace(pw);
132       }
133     }
134   }
135   
136 }
137
Popular Tags