001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006: * Contact: sequoia@continuent.org
007: *
008: * Licensed under the Apache License, Version 2.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: * Initial developer(s): Mathieu Peltier.
021: * Contributor(s): _______________________.
022: */package org.continuent.sequoia.common.exceptions;
023:
024: import java.io.PrintStream;
025: import java.io.PrintWriter;
026: import java.io.Serializable;
027:
028: /**
029: * Sequoia base exception.
030: *
031: * @author <a href="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
032: * @version 1.0
033: */
034: public class SequoiaException extends Exception implements Serializable {
035: private static final long serialVersionUID = -1899348090329064503L;
036:
037: /** Optional exception cause */
038: protected Throwable cause;
039:
040: /**
041: * Creates a new <code>SequoiaException</code> instance.
042: */
043: public SequoiaException() {
044: }
045:
046: /**
047: * Creates a new <code>SequoiaException</code> instance.
048: *
049: * @param message the error message
050: */
051: public SequoiaException(String message) {
052: super (message);
053: }
054:
055: /**
056: * Creates a new <code>SequoiaException</code> instance.
057: *
058: * @param cause the root cause
059: */
060: public SequoiaException(Throwable cause) {
061: this .cause = cause;
062: }
063:
064: /**
065: * Creates a new <code>SequoiaException</code> instance.
066: *
067: * @param message the error message
068: * @param cause the root cause
069: */
070: public SequoiaException(String message, Throwable cause) {
071: super (message);
072: this .cause = cause;
073: }
074:
075: /**
076: * Gets the root cause of this exception.
077: *
078: * @return a <code>Throwable</code> object
079: */
080: public Throwable getCause() {
081: return cause;
082: }
083:
084: /**
085: * @see java.lang.Throwable#fillInStackTrace()
086: */
087: public synchronized Throwable fillInStackTrace() {
088: if (cause != null) {
089: return cause.fillInStackTrace();
090: } else {
091: return super .fillInStackTrace();
092: }
093: }
094:
095: /**
096: * @see java.lang.Throwable#getStackTrace()
097: */
098: public StackTraceElement[] getStackTrace() {
099: if (cause != null) {
100: return cause.getStackTrace();
101: } else {
102: return super .getStackTrace();
103: }
104: }
105:
106: /**
107: * @see java.lang.Throwable#getMessage()
108: */
109: public String getMessage() {
110: if (cause != null) {
111: return cause.getMessage();
112: } else {
113: return super .getMessage();
114: }
115: }
116:
117: /**
118: * @see java.lang.Throwable#printStackTrace()
119: */
120: public void printStackTrace() {
121: if (cause != null) {
122: cause.printStackTrace();
123: } else {
124: super .printStackTrace();
125: }
126: }
127:
128: /**
129: * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
130: */
131: public void printStackTrace(PrintStream arg0) {
132: if (cause != null) {
133: cause.printStackTrace(arg0);
134: } else {
135: super .printStackTrace(arg0);
136: }
137: }
138:
139: /**
140: * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
141: */
142: public void printStackTrace(PrintWriter arg0) {
143: if (cause != null) {
144: cause.printStackTrace(arg0);
145: } else {
146: super .printStackTrace(arg0);
147: }
148: }
149:
150: /**
151: * @see java.lang.Throwable#setStackTrace(java.lang.StackTraceElement[])
152: */
153: public void setStackTrace(StackTraceElement[] arg0) {
154: if (cause != null) {
155: cause.setStackTrace(arg0);
156: } else {
157: super.setStackTrace(arg0);
158: }
159: }
160:
161: }
|