001: /*---------------------------------------------------------------------------*\
002: $Id: CurnException.java 7041 2007-09-09 01:04:47Z bmc $
003: ---------------------------------------------------------------------------
004: This software is released under a BSD-style license:
005:
006: Copyright (c) 2004-2007 Brian M. Clapper. All rights reserved.
007:
008: Redistribution and use in source and binary forms, with or without
009: modification, are permitted provided that the following conditions are
010: met:
011:
012: 1. Redistributions of source code must retain the above copyright notice,
013: this list of conditions and the following disclaimer.
014:
015: 2. The end-user documentation included with the redistribution, if any,
016: must include the following acknowlegement:
017:
018: "This product includes software developed by Brian M. Clapper
019: (bmc@clapper.org, http://www.clapper.org/bmc/). That software is
020: copyright (c) 2004-2007 Brian M. Clapper."
021:
022: Alternately, this acknowlegement may appear in the software itself,
023: if wherever such third-party acknowlegements normally appear.
024:
025: 3. Neither the names "clapper.org", "curn", nor any of the names of the
026: project contributors may be used to endorse or promote products
027: derived from this software without prior written permission. For
028: written permission, please contact bmc@clapper.org.
029:
030: 4. Products derived from this software may not be called "curn", nor may
031: "clapper.org" appear in their names without prior written permission
032: of Brian M. Clapper.
033:
034: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
036: MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
037: NO EVENT SHALL BRIAN M. CLAPPER BE LIABLE FOR ANY DIRECT, INDIRECT,
038: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
039: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
040: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
041: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
042: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
043: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
044: \*---------------------------------------------------------------------------*/
045:
046: package org.clapper.curn;
047:
048: import org.clapper.util.misc.NestedException;
049:
050: /**
051: * <tt>CurnException</tt> is the base class for all exceptions thrown
052: * by this tool.
053: *
054: * @version <tt>$Revision: 7041 $</tt>
055: */
056: public class CurnException extends NestedException {
057: /*----------------------------------------------------------------------*\
058: Private Static Variables
059: \*----------------------------------------------------------------------*/
060:
061: /*----------------------------------------------------------------------*\
062: Constructor
063: \*----------------------------------------------------------------------*/
064:
065: /**
066: * Default constructor, for an exception with no nested exception and
067: * no message.
068: */
069: public CurnException() {
070: super ();
071: }
072:
073: /**
074: * Constructs an exception containing another exception, but no message
075: * of its own.
076: *
077: * @param exception the exception to contain
078: */
079: public CurnException(Throwable exception) {
080: super (exception);
081: }
082:
083: /**
084: * Constructs an exception containing an error message, but no
085: * nested exception.
086: *
087: * @param message the message to associate with this exception
088: */
089: public CurnException(String message) {
090: super (message);
091: }
092:
093: /**
094: * Constructs an exception containing another exception and a message.
095: *
096: * @param message the message to associate with this exception
097: * @param exception the exception to contain
098: */
099: public CurnException(String message, Throwable exception) {
100: super (message, exception);
101: }
102:
103: /**
104: * Constructs an exception containing a resource bundle name, a message
105: * key, and a default message (in case the resource bundle can't be
106: * found). Using this constructor is equivalent to calling the
107: * {@link #CurnException(String,String,String,Object[])} constructor,
108: * with a null pointer for the <tt>Object[]</tt> parameter.
109: * Calls to {@link NestedException#getMessage(Locale)} will attempt to
110: * retrieve the top-most message (i.e., the message from this exception,
111: * not from nested exceptions) by querying the named resource bundle.
112: * Calls to {@link NestedException#printStackTrace(PrintWriter,Locale)}
113: * will do the same, where applicable. The message is not retrieved
114: * until one of those methods is called, because the desired locale is
115: * passed into <tt>getMessage()</tt> and <tt>printStackTrace()</tt>,
116: * not this constructor.
117: *
118: * @param bundleName resource bundle name
119: * @param messageKey the key to the message to find in the bundle
120: * @param defaultMsg the default message
121: *
122: * @see #CurnException(String,String,String,Object[])
123: * @see NestedException#getMessage(Locale)
124: */
125: public CurnException(String bundleName, String messageKey,
126: String defaultMsg) {
127: super (bundleName, messageKey, defaultMsg);
128: }
129:
130: /**
131: * Constructs an exception containing a resource bundle name, a message
132: * key, and a default message (in case the resource bundle can't be
133: * found). Using this constructor is equivalent to calling the
134: * {@link #CurnException(String,String,String,Object[],Throwable)}
135: * constructor, with a null pointer for the <tt>Object[]</tt> parameter.
136: * Calls to {@link NestedException#getMessage(Locale)} will attempt to
137: * retrieve the top-most message (i.e., the message from this exception,
138: * not from nested exceptions) by querying the named resource bundle.
139: * Calls to {@link NestedException#printStackTrace(PrintWriter,Locale)}
140: * will do the same, where applicable. The message is not retrieved
141: * until one of those methods is called, because the desired locale is
142: * passed into <tt>getMessage()</tt> and <tt>printStackTrace()</tt>,
143: * not this constructor.
144: *
145: * @param bundleName resource bundle name
146: * @param messageKey the key to the message to find in the bundle
147: * @param defaultMsg the default message
148: * @param msgParams parameters to the message, if any, or null
149: *
150: * @see #CurnException(String,String,String,Object[],Throwable)
151: * @see NestedException#getMessage(Locale)
152: */
153: public CurnException(String bundleName, String messageKey,
154: String defaultMsg, Object[] msgParams) {
155: super (bundleName, messageKey, defaultMsg, msgParams);
156: }
157:
158: /**
159: * Constructs an exception containing a resource bundle name, a message
160: * key, a default message (in case the resource bundle can't be found), and
161: * another exception. Using this constructor is equivalent to calling the
162: * {@link #CurnException(String,String,String,Object[],Throwable)}
163: * constructor, with a null pointer for the <tt>Object[]</tt>
164: * parameter. Calls to {@link #getMessage(Locale)} will attempt to
165: * retrieve the top-most message (i.e., the message from this
166: * exception, not from nested exceptions) by querying the named
167: * resource bundle. Calls to
168: * {@link #printStackTrace(PrintWriter,Locale)} will do the same, where
169: * applicable. The message is not retrieved until one of those methods
170: * is called, because the desired locale is passed into
171: * <tt>getMessage()</tt> and <tt>printStackTrace()</tt>, not this
172: * constructor.
173: *
174: * @param bundleName resource bundle name
175: * @param messageKey the key to the message to find in the bundle
176: * @param defaultMsg the default message
177: * @param exception the exception to nest
178: *
179: * @see #CurnException(String,String,String,Object[],Throwable)
180: * @see NestedException#getMessage(Locale)
181: */
182: public CurnException(String bundleName, String messageKey,
183: String defaultMsg, Throwable exception) {
184: this (bundleName, messageKey, defaultMsg, null, exception);
185: }
186:
187: /**
188: * Constructs an exception containing a resource bundle name, a message
189: * key, a default message format (in case the resource bundle can't be
190: * found), arguments to be incorporated in the message via
191: * <tt>java.text.MessageFormat</tt>, and another exception.
192: * Calls to {@link #getMessage(Locale)} will attempt to retrieve the
193: * top-most message (i.e., the message from this exception, not from
194: * nested exceptions) by querying the named resource bundle. Calls to
195: * {@link #printStackTrace(PrintWriter,Locale)} will do the same, where
196: * applicable. The message is not retrieved until one of those methods
197: * is called, because the desired locale is passed into
198: * <tt>getMessage()</tt> and <tt>printStackTrace()</tt>, not this
199: * constructor.
200: *
201: * @param bundleName resource bundle name
202: * @param messageKey the key to the message to find in the bundle
203: * @param defaultMsg the default message
204: * @param msgParams parameters to the message, if any, or null
205: * @param exception exception to be nested
206: *
207: * @see #CurnException(String,String,String,Object[])
208: * @see NestedException#getMessage(Locale)
209: */
210: public CurnException(String bundleName, String messageKey,
211: String defaultMsg, Object[] msgParams, Throwable exception) {
212: super(bundleName, messageKey, defaultMsg, msgParams, exception);
213: }
214: }
|