001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: * Paul Mahar
021: *
022: */
023: package org.enhydra.kelp.common.codegen;
024:
025: // Kelp imports
026: import org.enhydra.kelp.common.Constants; //
027: import java.io.PrintStream;
028:
029: /**
030: * The WebAppException is thrown for exceptions in the
031: * WebAppUtil class.
032: */
033: public class CodeGenException extends Exception {
034: private Throwable parent = null;
035: private boolean decoy = false;
036:
037: /**
038: * Create a GeneratorException with a specified error message.
039: *
040: * @param message
041: * Message providing information on the nature of the exception.
042: */
043: public CodeGenException(String message) {
044: super (message);
045: }
046:
047: /**
048: * Constructor declaration
049: *
050: *
051: * @param hidden
052: *
053: * @see
054: */
055: public CodeGenException(Throwable hidden) {
056: super (new String());
057: parent = hidden.fillInStackTrace();
058: decoy = true;
059: }
060:
061: /**
062: * Constructor declaration
063: *
064: *
065: * @param chain
066: * @param message
067: *
068: * @see
069: */
070: public CodeGenException(Throwable chain, String message) {
071: super (message);
072: parent = chain.fillInStackTrace();
073: }
074:
075: /**
076: * Method declaration
077: *
078: *
079: * @return
080: *
081: * @see
082: */
083: public String getMessage() {
084: StringBuffer buf = new StringBuffer();
085:
086: if ((!decoy) || (parent == null)) {
087: buf.append(super .getMessage());
088: }
089: if (parent != null) {
090: buf.append('\n');
091: buf.append(Constants.TAB4);
092: buf.append(parent.getMessage());
093: }
094: return buf.toString();
095: }
096:
097: public void printStackTrace() {
098: super .printStackTrace();
099: if (parent != null) {
100: parent.printStackTrace();
101: }
102: }
103:
104: public void printStackTrace(PrintStream stream) {
105: super.printStackTrace(stream);
106: if (parent != null) {
107: parent.printStackTrace(stream);
108: }
109: }
110:
111: }
|