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 685685 2008-08-13 21:43:27Z nbubna $
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       * @since 1.5
54       */
55      public VelocityException(final String exceptionMessage, final Throwable wrapped)
56      {
57          super(exceptionMessage);
58          this.wrapped = wrapped;
59          ExceptionUtils.setCause(this, wrapped);
60      }
61  
62      /**
63       * @param wrapped A throwable object that caused the Exception.
64       * @since 1.5
65       */
66      public VelocityException(final Throwable wrapped)
67      {
68          super();
69          this.wrapped = wrapped;
70          ExceptionUtils.setCause(this, wrapped);
71      }
72  
73      /**
74       *  returns the wrapped Throwable that caused this
75       *  MethodInvocationException to be thrown
76       *
77       *  @return Throwable thrown by method invocation
78       *  @since 1.5
79       */
80      public Throwable getWrappedThrowable()
81      {
82          return wrapped;
83      }
84  }