001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * - Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * - Redistribution in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * Neither the name of Sun Microsystems, Inc. or the names of
017: * contributors may be used to endorse or promote products derived
018: * from this software without specific prior written permission.
019: *
020: * This software is provided "AS IS," without a warranty of any
021: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026: * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027: * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028: * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029: * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030: * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031: * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032: *
033: * You acknowledge that Software is not designed, licensed or intended
034: * any nuclear facility.
035: */
036:
037: package com.sun.portal.community.template;
038:
039: import java.lang.Exception;
040:
041: import java.io.PrintWriter;
042: import java.io.BufferedReader;
043: import java.io.PrintStream;
044: import java.io.PrintWriter;
045:
046: /**
047: * A TemplateException is thrown when there is an unrecoverable error
048: * in template implementation.
049: **/
050: public class TemplateException extends Exception {
051:
052: protected Throwable wrapped = null;
053:
054: /**
055: * Constructs a new exception with the specified message, indicating an
056: * error in the provider as happened.<br><br>
057: *
058: * @param msg The descriptive message.
059: */
060: public TemplateException(String msg) {
061: super (msg);
062: }
063:
064: /**
065: * Constructs a new exception with the specified message, and the original
066: * <code>exception</code> or <code>error</code>, indicating an error in the
067: * template as happened.<br><br>
068: *
069: * @param msg The descriptive message.
070: * @param e The original <code>exception</code> or <code>error</code>.
071: */
072: public TemplateException(String msg, Throwable t) {
073: super (msg);
074: wrapped = t;
075: }
076:
077: public TemplateException(Throwable t) {
078: super ();
079: wrapped = t;
080: }
081:
082: public Throwable getWrapped() {
083: return wrapped;
084: }
085:
086: public String toString() {
087: StringBuffer b = new StringBuffer();
088:
089: b.append(super .toString());
090: if (getWrapped() != null) {
091: b.append(wrapped.toString());
092: }
093:
094: return b.toString();
095: }
096:
097: public void printStackTrace() {
098: super .printStackTrace();
099: if (getWrapped() != null) {
100: wrapped.printStackTrace();
101: }
102: }
103:
104: public void printStackTrace(PrintStream s) {
105: super .printStackTrace(s);
106: if (getWrapped() != null) {
107: wrapped.printStackTrace(s);
108: }
109: }
110:
111: public void printStackTrace(PrintWriter s) {
112: super.printStackTrace(s);
113: if (getWrapped() != null) {
114: wrapped.printStackTrace(s);
115: }
116: }
117: }
|