001: /*
002: * Copyright 1999-2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.jxpath;
017:
018: /**
019: * Thrown when a problem with configuration with the JXPathContextFactories
020: * exists. This error will typically be thrown when the class of a
021: * factory specified in the system properties cannot be found
022: * or instantiated.
023: *
024: * @author Dmitri Plotnikov
025: * @version $Revision: 1.5 $ $Date: 2004/02/29 14:17:42 $
026: */
027:
028: public class JXPathContextFactoryConfigurationError extends Error {
029:
030: /** @serial */
031: private Exception exception;
032:
033: /**
034: * Create a new <code>JXPathContextFactoryConfigurationError</code> with no
035: * detail mesage.
036: */
037:
038: public JXPathContextFactoryConfigurationError() {
039: super ();
040: this .exception = null;
041: }
042:
043: /**
044: * Create a new <code>JXPathContextFactoryConfigurationError</code> with
045: * the <code>String </code> specified as an error message.
046: *
047: * @param msg The error message for the exception.
048: */
049:
050: public JXPathContextFactoryConfigurationError(String msg) {
051: super (msg);
052: this .exception = null;
053: }
054:
055: /**
056: * Create a new <code>JXPathContextFactoryConfigurationError</code> with a
057: * given <code>Exception</code> base cause of the error.
058: *
059: * @param e The exception to be encapsulated in a
060: * JXPathContextFactoryConfigurationError.
061: */
062:
063: public JXPathContextFactoryConfigurationError(Exception e) {
064: super (e.toString());
065: this .exception = e;
066: }
067:
068: /**
069: * Create a new <code>JXPathContextFactoryConfigurationError</code> with the
070: * given <code>Exception</code> base cause and detail message.
071: *
072: * @param e The exception to be encapsulated in a
073: * JXPathContextFactoryConfigurationError
074: * @param msg The detail message.
075: */
076:
077: public JXPathContextFactoryConfigurationError(Exception e,
078: String msg) {
079: super (msg);
080: this .exception = e;
081: }
082:
083: /**
084: * Return the message (if any) for this error . If there is no
085: * message for the exception and there is an encapsulated
086: * exception then the message of that exception will be returned.
087: *
088: * @return The error message.
089: */
090:
091: public String getMessage() {
092: String message = super .getMessage();
093:
094: if (message == null && exception != null) {
095: return exception.getMessage();
096: }
097:
098: return message;
099: }
100:
101: /**
102: * Return the actual exception (if any) that caused this exception to
103: * be raised.
104: *
105: * @return The encapsulated exception, or null if there is none.
106: */
107:
108: public Exception getException() {
109: return exception;
110: }
111: }
|