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