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.providers.window;
015:
016: import java.lang.Exception;
017:
018: import java.io.PrintWriter;
019: import java.io.BufferedReader;
020: import java.io.PrintStream;
021: import java.io.PrintWriter;
022:
023: import com.sun.portal.container.ErrorCode;
024:
025: /**
026: * A WindowException is thrown when error
027: * message can be displayed on the Provider.
028: * It is thrown when error is not as serious as
029: * provider exception.
030: *
031: **/
032: public class WindowException extends Exception {
033:
034: protected Throwable _wrapped = null;
035: protected ErrorCode _errorCode = null;
036:
037: /**
038: * Constructs a new exception with the specified message, indicating an
039: * error in the provider as happened.<br><br>
040: *
041: * @param msg The descriptive message.
042: */
043: public WindowException(ErrorCode code, String msg) {
044: super (msg);
045: _errorCode = code;
046: }
047:
048: /**
049: * Constructs a new exception with the specified message, and the original
050: * <code>exception</code> or <code>error</code>, indicating an error in the
051: * container as happened.<br><br>
052: *
053: * @param msg The descriptive message.
054: * @param e The original <code>exception</code> or <code>error</code>.
055: */
056: public WindowException(ErrorCode code, String msg, Throwable e) {
057: super (msg);
058: _wrapped = e;
059: _errorCode = code;
060: }
061:
062: public Throwable getWrapped() {
063: return _wrapped;
064: }
065:
066: public String toString() {
067: StringBuffer b = new StringBuffer();
068: b.append(_errorCode.toString() + ":");
069: b.append(super .toString());
070: if (getWrapped() != null) {
071: b.append(_wrapped.toString());
072: }
073:
074: return b.toString();
075: }
076:
077: public void printStackTrace() {
078: super .printStackTrace();
079: if (getWrapped() != null) {
080: _wrapped.printStackTrace();
081: }
082: }
083:
084: public void printStackTrace(PrintStream s) {
085: super .printStackTrace(s);
086: if (getWrapped() != null) {
087: _wrapped.printStackTrace(s);
088: }
089: }
090:
091: public void printStackTrace(PrintWriter s) {
092: super .printStackTrace(s);
093: if (getWrapped() != null) {
094: _wrapped.printStackTrace(s);
095: }
096: }
097:
098: public ErrorCode getErrorCode() {
099: return _errorCode;
100: }
101: }
|