View Javadoc

1   /*
2    * Copyright 1999-2004 The Apache Software Foundation
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.commons.jxpath;
17  
18  /***
19   * Thrown when a problem with configuration with the JXPathContextFactories
20   * exists. This error will typically be thrown when the class of a
21   * factory specified in the system properties cannot be found
22   * or instantiated.
23   *
24   * @author Dmitri Plotnikov
25   * @version $Revision: 1.5 $ $Date: 2004/02/29 14:17:42 $
26   */
27  
28  public class JXPathContextFactoryConfigurationError extends Error {
29  
30      /*** @serial */
31      private Exception exception;
32  
33      /***
34       * Create a new <code>JXPathContextFactoryConfigurationError</code> with no
35       * detail mesage.
36       */
37  
38       public JXPathContextFactoryConfigurationError() {
39           super();
40           this.exception = null;
41       }
42  
43      /***
44       * Create a new <code>JXPathContextFactoryConfigurationError</code> with
45       * the <code>String </code> specified as an error message.
46       *
47       * @param msg The error message for the exception.
48       */
49  
50      public JXPathContextFactoryConfigurationError(String msg) {
51          super(msg);
52          this.exception = null;
53      }
54  
55  
56      /***
57       * Create a new <code>JXPathContextFactoryConfigurationError</code> with a
58       * given <code>Exception</code> base cause of the error.
59       *
60       * @param e The exception to be encapsulated in a
61       * JXPathContextFactoryConfigurationError.
62       */
63  
64      public JXPathContextFactoryConfigurationError(Exception e) {
65          super(e.toString());
66          this.exception = e;
67      }
68  
69      /***
70       * Create a new <code>JXPathContextFactoryConfigurationError</code> with the
71       * given <code>Exception</code> base cause and detail message.
72       *
73       * @param e The exception to be encapsulated in a
74       * JXPathContextFactoryConfigurationError
75       * @param msg The detail message.
76       */
77  
78      public JXPathContextFactoryConfigurationError(Exception e, String msg) {
79          super(msg);
80          this.exception = e;
81      }
82  
83  
84      /***
85       * Return the message (if any) for this error . If there is no
86       * message for the exception and there is an encapsulated
87       * exception then the message of that exception will be returned.
88       *
89       * @return The error message.
90       */
91  
92      public String getMessage () {
93          String message = super.getMessage ();
94  
95          if (message == null && exception != null) {
96              return exception.getMessage();
97          }
98  
99          return message;
100     }
101 
102     /***
103      * Return the actual exception (if any) that caused this exception to
104      * be raised.
105      *
106      * @return The encapsulated exception, or null if there is none.
107      */
108 
109     public Exception getException () {
110         return exception;
111     }
112 }