001: /*
002: * $Id: StartupException.java,v 1.1 2003/08/15 20:23:20 ajzeneski Exp $
003: *
004: * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
005: *
006: * Permission is hereby granted, free of charge, to any person obtaining a
007: * copy of this software and associated documentation files (the "Software"),
008: * to deal in the Software without restriction, including without limitation
009: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
010: * and/or sell copies of the Software, and to permit persons to whom the
011: * Software is furnished to do so, subject to the following conditions:
012: *
013: * The above copyright notice and this permission notice shall be included
014: * in all copies or substantial portions of the Software.
015: *
016: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
017: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
018: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
019: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
020: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
021: * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
022: * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023: *
024: */
025: package org.ofbiz.base.start;
026:
027: import java.io.PrintStream;
028: import java.io.PrintWriter;
029:
030: /**
031: * StartupException
032: *
033: * @author <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a>
034: * @version $Revision: 1.1 $
035: * @since 2.2
036: */
037: public class StartupException extends Exception {
038:
039: Throwable nested = null;
040:
041: /**
042: * Creates new <code>StartupException</code> without detail message.
043: */
044: public StartupException() {
045: super ();
046: }
047:
048: /**
049: * Constructs an <code>StartupException</code> with the specified detail message.
050: * @param msg the detail message.
051: */
052: public StartupException(String msg) {
053: super (msg);
054: }
055:
056: /**
057: * Constructs an <code>StartupException</code> with the specified detail message and nested Exception.
058: * @param msg the detail message.
059: */
060: public StartupException(String msg, Throwable nested) {
061: super (msg);
062: this .nested = nested;
063: }
064:
065: /**
066: * Constructs an <code>StartupException</code> with the specified detail message and nested Exception.
067: * @param msg the detail message.
068: */
069: public StartupException(Throwable nested) {
070: super ();
071: this .nested = nested;
072: }
073:
074: /** Returns the detail message, including the message from the nested exception if there is one. */
075: public String getMessage() {
076: if (nested != null) {
077: return super .getMessage() + " (" + nested.getMessage()
078: + ")";
079: } else {
080: return super .getMessage();
081: }
082: }
083:
084: /** Returns the detail message, NOT including the message from the nested exception. */
085: public String getNonNestedMessage() {
086: return super .getMessage();
087: }
088:
089: /** Returns the nested exception if there is one, null if there is not. */
090: public Throwable getNested() {
091: if (nested == null) {
092: return this ;
093: }
094: return nested;
095: }
096:
097: /** Prints the composite message to System.err. */
098: public void printStackTrace() {
099: super .printStackTrace();
100: if (nested != null) {
101: nested.printStackTrace();
102: }
103: }
104:
105: /** Prints the composite message and the embedded stack trace to the specified stream ps. */
106: public void printStackTrace(PrintStream ps) {
107: super .printStackTrace(ps);
108: if (nested != null) {
109: nested.printStackTrace(ps);
110: }
111: }
112:
113: /** Prints the composite message and the embedded stack trace to the specified print writer pw. */
114: public void printStackTrace(PrintWriter pw) {
115: super.printStackTrace(pw);
116: if (nested != null) {
117: nested.printStackTrace(pw);
118: }
119: }
120: }
|