KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > exceptions > DodsBaseException


1 //Enhydra API javadoc generation
2
/*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: DodsBaseException.java,v 1.1 2004/09/03 13:42:37 sinisa Exp $
23  */

24
25 package org.enhydra.dods.exceptions;
26
27 import java.io.*;
28
29 /**
30  * Exception used as a base for creating an exception that has a chain of
31  * exceptions that lead to the derived exception. Very useful for interfaces
32  * where the implementation exception is not known.
33  */

34 public class DodsBaseException extends Exception JavaDoc {
35     private Throwable JavaDoc cause;
36
37     /**
38      * Construct an exception without a specified cause.
39      *
40      * @param msg The message associated with the exception.
41      */

42     public DodsBaseException(String JavaDoc msg) {
43         super(msg);
44         cause = null;
45     }
46
47     /**
48      * Construct an exception with an associated causing exception.
49      *
50      * @param msg The message associated with the exception.
51      * @param cause The error or exception that cause this
52      * exception.
53      */

54     public DodsBaseException(String JavaDoc msg,
55                             Throwable JavaDoc cause) {
56         super(msg);
57         this.cause = cause;
58     }
59
60     /**
61      * Construct an exception from a causing exception.
62      *
63      * @param cause The error or exception that cause this
64      * exception. The message will be take be this object's
65      * messasge.
66      */

67     public DodsBaseException(Throwable JavaDoc cause) {
68         super(DodsBaseExceptionUtil.makeMessage(cause));
69         this.cause = cause;
70     }
71
72     /**
73      * Return the message associated with this exception. If causes
74      * are included, they will be appended to the message.
75      */

76     public String JavaDoc getMessage() {
77         return DodsBaseExceptionUtil.getMessage(this, super.getMessage());
78     }
79
80     /**
81      * Get the causing exception associated with this exception.
82      * @return The causing exception or null if no cause is specified.
83      */

84     public Throwable JavaDoc getCause() {
85         return cause;
86     }
87
88     /**
89      * Prints this ChainedException and its backtrace, and the causes
90      * and their stack traces to the standard error stream.
91      */

92     public void printStackTrace() {
93         super.printStackTrace();
94         DodsBaseExceptionUtil.printCauseTrace(this);
95     }
96
97     /**
98      * Prints this ChainedException and its backtrace, and the causes
99      * 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     
116     
117     
118 }
119
Popular Tags