001: //Enhydra API javadoc generation
002: /*
003: * Enhydra Java Application Server Project
004: *
005: * The contents of this file are subject to the Enhydra Public License
006: * Version 1.1 (the "License"); you may not use this file except in
007: * compliance with the License. You may obtain a copy of the License on
008: * the Enhydra web site ( http://www.enhydra.org/ ).
009: *
010: * Software distributed under the License is distributed on an "AS IS"
011: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
012: * the License for the specific terms governing rights and limitations
013: * under the License.
014: *
015: * The Initial Developer of the Enhydra Application Server is Lutris
016: * Technologies, Inc. The Enhydra Application Server and portions created
017: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
018: * All Rights Reserved.
019: *
020: * Contributor(s):
021: *
022: * $Id: DodsBaseException.java,v 1.1 2007-01-24 16:59:09 sinisa Exp $
023: */
024:
025: package org.enhydra.dods.exceptions;
026:
027: import java.io.*;
028:
029: /**
030: * Exception used as a base for creating an exception that has a chain of
031: * exceptions that lead to the derived exception. Very useful for interfaces
032: * where the implementation exception is not known.
033: */
034: public class DodsBaseException extends Exception {
035: private Throwable cause;
036:
037: /**
038: * Construct an exception without a specified cause.
039: *
040: * @param msg The message associated with the exception.
041: */
042: public DodsBaseException(String msg) {
043: super (msg);
044: cause = null;
045: }
046:
047: /**
048: * Construct an exception with an associated causing exception.
049: *
050: * @param msg The message associated with the exception.
051: * @param cause The error or exception that cause this
052: * exception.
053: */
054: public DodsBaseException(String msg, Throwable cause) {
055: super (msg);
056: this .cause = cause;
057: }
058:
059: /**
060: * Construct an exception from a causing exception.
061: *
062: * @param cause The error or exception that cause this
063: * exception. The message will be take be this object's
064: * messasge.
065: */
066: public DodsBaseException(Throwable cause) {
067: super (DodsBaseExceptionUtil.makeMessage(cause));
068: this .cause = cause;
069: }
070:
071: /**
072: * Return the message associated with this exception. If causes
073: * are included, they will be appended to the message.
074: */
075: public String getMessage() {
076: return DodsBaseExceptionUtil.getMessage(this , super
077: .getMessage());
078: }
079:
080: /**
081: * Get the causing exception associated with this exception.
082: * @return The causing exception or null if no cause is specified.
083: */
084: public Throwable getCause() {
085: return cause;
086: }
087:
088: /**
089: * Prints this ChainedException and its backtrace, and the causes
090: * and their stack traces to the standard error stream.
091: */
092: public void printStackTrace() {
093: super .printStackTrace();
094: DodsBaseExceptionUtil.printCauseTrace(this );
095: }
096:
097: /**
098: * Prints this ChainedException and its backtrace, and the causes
099: * and their stack traces to the e specified print stream.
100: */
101: public void printStackTrace(PrintStream s) {
102: super .printStackTrace(s);
103: DodsBaseExceptionUtil.printCauseTrace(this , s);
104: }
105:
106: /**
107: * Prints this ChainedException and its backtrace, and the causes
108: * and their stack traces to the e specified print writer.
109: */
110: public void printStackTrace(PrintWriter s) {
111: super.printStackTrace(s);
112: DodsBaseExceptionUtil.printCauseTrace(this, s);
113: }
114:
115: }
|