01: package org.apache.velocity.exception;
02:
03: import org.apache.velocity.util.ExceptionUtils;
04:
05: /*
06: * Licensed to the Apache Software Foundation (ASF) under one
07: * or more contributor license agreements. See the NOTICE file
08: * distributed with this work for additional information
09: * 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 extends RuntimeException {
32: /**
33: * Version Id for serializable
34: */
35: private static final long serialVersionUID = 1251243065134956045L;
36:
37: private final Throwable wrapped;
38:
39: /**
40: * @param exceptionMessage The message to register.
41: */
42: public VelocityException(final String exceptionMessage) {
43: super (exceptionMessage);
44: wrapped = null;
45: }
46:
47: /**
48: * @param exceptionMessage The message to register.
49: * @param wrapped A throwable object that caused the Exception.
50: */
51: public VelocityException(final String exceptionMessage,
52: final Throwable wrapped) {
53: super (exceptionMessage);
54: this .wrapped = wrapped;
55: ExceptionUtils.setCause(this , wrapped);
56: }
57:
58: /**
59: * @param wrapped A throwable object that caused the Exception.
60: */
61: public VelocityException(final Throwable wrapped) {
62: super ();
63: this .wrapped = wrapped;
64: ExceptionUtils.setCause(this , wrapped);
65: }
66:
67: /**
68: * returns the wrapped Throwable that caused this
69: * MethodInvocationException to be thrown
70: *
71: * @return Throwable thrown by method invocation
72: */
73: public Throwable getWrappedThrowable() {
74: return wrapped;
75: }
76: }
|