KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > base > start > StartupException


1 /*
2  * $Id: StartupException.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.base.start;
26
27 import java.io.PrintStream JavaDoc;
28 import java.io.PrintWriter JavaDoc;
29
30 /**
31  * StartupException
32  *
33  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
34  * @version $Rev: 5462 $
35  * @since 2.2
36  */

37 public class StartupException extends Exception JavaDoc {
38     
39     Throwable JavaDoc nested = null;
40
41     /**
42      * Creates new <code>StartupException</code> without detail message.
43      */

44     public StartupException() {
45         super();
46     }
47
48     /**
49      * Constructs an <code>StartupException</code> with the specified detail message.
50      * @param msg the detail message.
51      */

52     public StartupException(String JavaDoc msg) {
53         super(msg);
54     }
55
56     /**
57      * Constructs an <code>StartupException</code> with the specified detail message and nested Exception.
58      * @param msg the detail message.
59      */

60     public StartupException(String JavaDoc msg, Throwable JavaDoc nested) {
61         super(msg);
62         this.nested = nested;
63     }
64
65     /**
66      * Constructs an <code>StartupException</code> with the specified detail message and nested Exception.
67      * @param msg the detail message.
68      */

69     public StartupException(Throwable JavaDoc nested) {
70         super();
71         this.nested = nested;
72     }
73
74     /** Returns the detail message, including the message from the nested exception if there is one. */
75     public String JavaDoc getMessage() {
76         if (nested != null) {
77             return super.getMessage() + " (" + nested.getMessage() + ")";
78         } else {
79             return super.getMessage();
80         }
81     }
82
83     /** Returns the detail message, NOT including the message from the nested exception. */
84     public String JavaDoc getNonNestedMessage() {
85         return super.getMessage();
86     }
87
88     /** Returns the nested exception if there is one, null if there is not. */
89     public Throwable JavaDoc getNested() {
90         if (nested == null) {
91             return this;
92         }
93         return nested;
94     }
95
96     /** Prints the composite message to System.err. */
97     public void printStackTrace() {
98         super.printStackTrace();
99         if (nested != null) {
100             nested.printStackTrace();
101         }
102     }
103
104     /** Prints the composite message and the embedded stack trace to the specified stream ps. */
105     public void printStackTrace(PrintStream JavaDoc ps) {
106         super.printStackTrace(ps);
107         if (nested != null) {
108             nested.printStackTrace(ps);
109         }
110     }
111
112     /** Prints the composite message and the embedded stack trace to the specified print writer pw. */
113     public void printStackTrace(PrintWriter JavaDoc pw) {
114         super.printStackTrace(pw);
115         if (nested != null) {
116             nested.printStackTrace(pw);
117         }
118     }
119 }
120
Popular Tags