View Javadoc

1   package org.apache.velocity.exception;
2   
3   import org.apache.velocity.util.ExceptionUtils;
4   
5   /*
6    * Licensed to the Apache Software Foundation (ASF) under one
7    * or more contributor license agreements.  See the NOTICE file
8    * distributed with this work for additional information
9    * regarding copyright ownership.  The ASF licenses this file
10   * to you under the Apache License, Version 2.0 (the
11   * "License"); you may not use this file except in compliance
12   * with the License.  You may obtain a copy of the License at
13   *
14   *   http://www.apache.org/licenses/LICENSE-2.0
15   *
16   * Unless required by applicable law or agreed to in writing,
17   * software distributed under the License is distributed on an
18   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19   * KIND, either express or implied.  See the License for the
20   * specific language governing permissions and limitations
21   * under the License.    
22   */
23  
24  /**
25  *  Base class for Velocity runtime exceptions thrown to the 
26   * application layer.    
27   *
28   * @author <a href="mailto:kdowney@amberarcher.com">Kyle F. Downey</a>
29   * @version $Id: VelocityException.java 471260 2006-11-04 20:37:20Z henning $
30   */
31  public class VelocityException
32          extends RuntimeException
33  {
34      /**
35       * Version Id for serializable
36       */
37      private static final long serialVersionUID = 1251243065134956045L;
38  
39      private final Throwable wrapped;
40  
41      /**
42       * @param exceptionMessage The message to register.
43       */
44      public VelocityException(final String exceptionMessage)
45      {
46          super(exceptionMessage);
47          wrapped = null;
48      }
49  
50      /**
51       * @param exceptionMessage The message to register.
52       * @param wrapped A throwable object that caused the Exception.
53       */
54      public VelocityException(final String exceptionMessage, final Throwable wrapped)
55      {
56          super(exceptionMessage);
57          this.wrapped = wrapped;
58          ExceptionUtils.setCause(this, wrapped);
59      }
60  
61      /**
62       * @param wrapped A throwable object that caused the Exception.
63       */
64      public VelocityException(final Throwable wrapped)
65      {
66          super();
67          this.wrapped = wrapped;
68          ExceptionUtils.setCause(this, wrapped);
69      }
70  
71      /**
72       *  returns the wrapped Throwable that caused this
73       *  MethodInvocationException to be thrown
74       *
75       *  @return Throwable thrown by method invocation
76       */
77      public Throwable getWrappedThrowable()
78      {
79          return wrapped;
80      }
81  }