001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */
013:
014: package com.sun.portal.container;
015:
016: import java.lang.Exception;
017: import java.io.PrintWriter;
018: import java.io.BufferedReader;
019: import java.io.PrintStream;
020: import java.io.PrintWriter;
021:
022: /**
023: * A ContentException is thrown when there is an unrecoverable error
024: * occurs when a container is trying to obtain the content of a particular
025: * channel.
026: **/
027:
028: public class ContentException extends Exception {
029:
030: protected Throwable wrapped = null;
031: protected ErrorCode code = null;
032:
033: /**
034: * Constructs a new exception with the specified message, indicating an
035: * error in the provider as happened.<br><br>
036: *
037: * @param msg The descriptive message.
038: */
039: public ContentException(String msg) {
040: super (msg);
041: }
042:
043: /**
044: * Constructs a new exception with the specified message and an <code>error
045: * code</code>, indicating an
046: * error in the provider as happened.<br><br>
047: *
048: * @param msg The descriptive message.
049: * @param code The error code associate with the exception.
050: */
051: public ContentException(String msg, ErrorCode code) {
052: super (msg);
053: this .code = code;
054: }
055:
056: /**
057: * Constructs a new exception with the specified message, and the original
058: * <code>exception</code>, indicating an error in the
059: * container as happened.<br><br>
060: *
061: * @param msg The descriptive message.
062: * @param e The original <code>exception</code>.
063: */
064: public ContentException(String msg, Throwable e) {
065: super (msg);
066: wrapped = e;
067: }
068:
069: /**
070: * Constructs a new exception with the specified message, the <code>error
071: * code</code> and the original <code>exception</code>, indicating an error
072: * in the container as happened.<br><br>
073: *
074: * @param msg The descriptive message.
075: * @param code The error code associate with the exception.
076: * @param e The original <code>exception</code>.
077: */
078: public ContentException(String msg, ErrorCode code, Throwable e) {
079: super (msg);
080: wrapped = e;
081: this .code = code;
082: }
083:
084: public Throwable getWrapped() {
085: return wrapped;
086: }
087:
088: public ErrorCode getErrorCode() {
089: return code;
090: }
091:
092: public String toString() {
093: StringBuffer b = new StringBuffer();
094:
095: b.append(super .toString());
096: b.append(" error code ");
097: b.append(code);
098: if (getWrapped() != null) {
099: b.append(wrapped.toString());
100: }
101:
102: return b.toString();
103: }
104:
105: public void printStackTrace() {
106: super .printStackTrace();
107: if (getWrapped() != null) {
108: wrapped.printStackTrace();
109: }
110: }
111:
112: public void printStackTrace(PrintStream s) {
113: super .printStackTrace(s);
114: if (getWrapped() != null) {
115: wrapped.printStackTrace(s);
116: }
117: }
118:
119: public void printStackTrace(PrintWriter s) {
120: super.printStackTrace(s);
121: if (getWrapped() != null) {
122: wrapped.printStackTrace(s);
123: }
124: }
125: }
|