View Javadoc

1   /**
2    *  Copyright 2003-2006 Greg Luck
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  
17  
18  package net.sf.ehcache;
19  
20  /**
21   * A runtime Cache Exception, compatible with JDK1.3.
22   * <p/>
23   * Because JDK1.3 does not support chained exceptions or intial cause, this class has its own initialCause
24   * field and {@link #getInitialCause} accessor, to aid with debugging. The JDK1.4 initial cause mechanism is
25   * not used or populated. 
26   * <p/>
27   *
28   * @author Greg Luck
29   * @version $Id: CacheException.java 52 2006-04-24 14:50:03Z gregluck $
30   */
31  public class CacheException extends RuntimeException {
32  
33  
34      /**
35       * Enables the cause to be recorded in a way that supports pre-JDK1.4 JDKs.
36       */
37      private final Throwable initialCause;
38  
39      /**
40       * Constructor for the CacheException object.
41       */
42      public CacheException() {
43          super();
44          initialCause = null;
45      }
46  
47      /**
48       * Constructor for the CacheException object.
49       * @param message the exception detail message
50       */
51      public CacheException(String message) {
52          super(message);
53          initialCause = null;
54      }
55  
56  
57      /**
58       * Constructor for the CacheException object.
59       * @param message the exception detail message
60       * @param initialCause the cause of the exception
61       */
62      public CacheException(String message, Throwable initialCause) {
63          super(message);
64          this.initialCause = initialCause;
65      }
66  
67      /**
68       * The intiial cause of this Exception.
69       * @return the cause or null if this exception has no deeper cause.
70       */
71      public final Throwable getInitialCause() {
72          return initialCause;
73      }
74  
75  
76  }