1 package org.apache.velocity.exception; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.apache.velocity.runtime.parser.LogContext; 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$ 30 */ 31 public class VelocityException extends RuntimeException 32 { 33 /** 34 * Version Id for serializable 35 */ 36 private static final long serialVersionUID = 1251243065134956045L; 37 38 /** 39 * LogContext VTL location tracking context 40 */ 41 private LogContext logContext = null; 42 43 /** 44 * VTL vtlStackTrace, populated at construction when runtime.log.track_location is true 45 */ 46 private String vtlStackTrace[] = null; 47 48 /** 49 * @param exceptionMessage The message to register. 50 */ VelocityException(final String exceptionMessage)51 public VelocityException(final String exceptionMessage) 52 { 53 super(exceptionMessage); 54 } 55 56 /** 57 * @param exceptionMessage The message to register. 58 * @param wrapped A throwable object that caused the Exception. 59 * @since 1.5 60 */ VelocityException(final String exceptionMessage, final Throwable wrapped)61 public VelocityException(final String exceptionMessage, final Throwable wrapped) 62 { 63 super(exceptionMessage, wrapped); 64 } 65 66 /** 67 * @param exceptionMessage The message to register. 68 * @param wrapped A throwable object that caused the Exception. 69 * @param vtlStackTrace VTL stacktrace 70 * @since 2.2 71 */ VelocityException(final String exceptionMessage, final Throwable wrapped, final String[] vtlStackTrace)72 public VelocityException(final String exceptionMessage, final Throwable wrapped, final String[] vtlStackTrace) 73 { 74 super(exceptionMessage, wrapped); 75 this.vtlStackTrace = vtlStackTrace; 76 } 77 78 /** 79 * @param wrapped A throwable object that caused the Exception. 80 * @since 1.5 81 */ VelocityException(final Throwable wrapped)82 public VelocityException(final Throwable wrapped) 83 { 84 super(wrapped); 85 } 86 87 /** 88 * @param wrapped A throwable object that caused the Exception. 89 * @param vtlStackTrace VTL stacktrace 90 * @since 2.2 91 */ VelocityException(final Throwable wrapped, final String[] vtlStackTrace)92 public VelocityException(final Throwable wrapped, final String[] vtlStackTrace) 93 { 94 super(wrapped); 95 this.vtlStackTrace = vtlStackTrace; 96 } 97 98 /** 99 * returns the wrapped Throwable that caused this 100 * MethodInvocationException to be thrown 101 * 102 * @return Throwable thrown by method invocation 103 * @since 1.5 104 * @deprecated Use {@link java.lang.RuntimeException#getCause()} 105 */ getWrappedThrowable()106 public Throwable getWrappedThrowable() 107 { 108 return getCause(); 109 } 110 getVtlStackTrace()111 public String[] getVtlStackTrace() 112 { 113 return vtlStackTrace; 114 } 115 } 116