001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.desktop.taglib;
006:
007: import java.lang.Throwable;
008: import java.io.PrintStream;
009: import java.io.PrintWriter;
010: import javax.servlet.jsp.JspException;
011:
012: import com.sun.portal.desktop.DesktopServlet;
013: import com.sun.portal.desktop.TypedException;
014:
015: public class DesktopTaglibException extends JspException implements
016: TypedException {
017:
018: static public final int INVALID_TAG_SEQUENCE = 0;
019: static public final int INVALID_PROVIDER_TYPE = 1;
020: static public final int INVALID_PARAMETER = 2;
021: static public final int UNDEFINED_PARAMETER = 3;
022: static public final int EMPTY_CONTEXT = 4;
023: private String typedExceptionType = UNKNOWN_TYPE;
024:
025: static private final String exceptionMsg[] = {
026: "Invalid Tag Sequence : ", "Incompatible Provider : ",
027: "Invalid Parameter : ",
028: "Variable Undefined in Page Context : ",
029: "Taglib Context is empty : " };
030:
031: private Throwable wrapped = null;
032:
033: public DesktopTaglibException(String msg) {
034: super (msg);
035: }
036:
037: public DesktopTaglibException(int type, String additionalMsg) {
038: super (exceptionMsg[type] + additionalMsg);
039: }
040:
041: public DesktopTaglibException(int type) {
042: super (exceptionMsg[type]);
043: }
044:
045: public DesktopTaglibException(Throwable t) {
046: super (t.getMessage());
047: wrapped = t;
048: }
049:
050: public DesktopTaglibException(Throwable t, String additionalMsg) {
051: super (t.getMessage() + " - " + additionalMsg);
052: wrapped = t;
053: }
054:
055: /**
056: * Constructs a new exception with the specified message and the exception types defined in TypedException interface
057: * So that the proper error template is shown to user.
058: * @param additionalMsg
059: * @param exceptionType
060: */
061: public DesktopTaglibException(String additionalMsg,
062: String exceptionType) {
063: super (additionalMsg);
064: typedExceptionType = exceptionType;
065: }
066:
067: public Throwable getWrapped() {
068: return wrapped;
069: }
070:
071: public String toString() {
072: StringBuffer b = new StringBuffer();
073:
074: if (getWrapped() != null) {
075: b.append(wrapped.toString());
076: }
077: b.append(super .toString());
078:
079: return b.toString();
080: }
081:
082: public void printStackTrace() {
083: super .printStackTrace();
084: if (getWrapped() != null) {
085: wrapped.printStackTrace();
086: }
087: }
088:
089: public void printStackTrace(PrintStream s) {
090: super .printStackTrace(s);
091: if (getWrapped() != null) {
092: wrapped.printStackTrace(s);
093: }
094: }
095:
096: public void printStackTrace(PrintWriter s) {
097: super .printStackTrace(s);
098: if (getWrapped() != null) {
099: wrapped.printStackTrace(s);
100: }
101: }
102:
103: public String getType() {
104: return typedExceptionType;
105: }
106: }
|