geirm 01/04/22 17:41:37
Modified: src/java/org/apache/velocity/runtime/parser/node
ASTMethod.java PropertyExecutor.java
Log:
Additions from Tim Joyce.
ASTMethod : added rethrow - ...value() in doIntrospection() can throw for a
method in an arg, so we want to rethrow that.
PropExec : oversight... thanks tim...
Revision Changes Path
1.16 +17 -3
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
Index: ASTMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTMethod.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ASTMethod.java 2001/04/20 04:28:47 1.15
+++ ASTMethod.java 2001/04/23 00:41:37 1.16
@@ -84,7 +84,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: ASTMethod.java,v 1.15 2001/04/20 04:28:47 geirm Exp $
+ * @version $Id: ASTMethod.java,v 1.16 2001/04/23 00:41:37 geirm Exp $
*/
public class ASTMethod extends SimpleNode
{
@@ -134,7 +134,7 @@
* only be called at execute() / render() time
*/
private Method doIntrospection( InternalContextAdapter context, Class data)
- throws Exception
+ throws MethodInvocationException, Exception
{
/*
* Now the parameters have to be processed, there
@@ -225,9 +225,23 @@
if (method == null)
return null;
}
+ catch( MethodInvocationException mie )
+ {
+ /*
+ * this can come from the doIntrospection(), as the arg values
+ * are evaluated to find the right method signature. We just
+ * want to propogate it here, not do anything fancy
+ */
+
+ throw mie;
+ }
catch( Exception e )
{
- Runtime.error("ASTMethod.execute() : exception : " + e );
+ /*
+ * can come from the doIntropection() also, from Introspector
+ */
+
+ Runtime.error("ASTMethod.execute() : exception from introspection : " +
e);
return null;
}
1.7 +33 -6
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java
Index: PropertyExecutor.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PropertyExecutor.java 2001/04/18 12:25:28 1.6
+++ PropertyExecutor.java 2001/04/23 00:41:37 1.7
@@ -54,11 +54,11 @@
*/
import java.lang.reflect.Method;
-
-import org.apache.velocity.context.InternalContextAdapter;
-
import java.lang.reflect.InvocationTargetException;
+
import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.context.EventCartridge;
+import org.apache.velocity.context.InternalContextAdapter;
/**
* Returned the value of object property when executed.
@@ -137,17 +137,44 @@
}
catch( InvocationTargetException ite )
{
+ EventCartridge ec = context.getEventCartridge();
+
/*
- * the method we invoked threw an exception.
- * package and pass it up
+ * if we have an event cartridge, see if it wants to veto
+ * also, let non-Exception Throwables go...
*/
- throw new MethodInvocationException(
+ if ( ec != null && ite.getTargetException() instanceof
java.lang.Exception)
+ {
+ try
+ {
+ return ec.methodException( o.getClass(), methodUsed,
(Exception)ite.getTargetException() );
+ }
+ catch( Exception e )
+ {
+ throw new MethodInvocationException(
+ "Invocation of method '" + methodUsed + "'"
+ + " in " + o.getClass()
+ + " threw exception "
+ + ite.getTargetException().getClass(),
+ ite.getTargetException(), methodUsed );
+ }
+ }
+ else
+ {
+ /*
+ * no event cartridge to override. Just throw
+ */
+
+ throw new MethodInvocationException(
"Invocation of method '" + methodUsed + "'"
+ " in " + o.getClass()
+ " threw exception "
+ ite.getTargetException().getClass(),
ite.getTargetException(), methodUsed );
+
+
+ }
}
catch( IllegalArgumentException iae )
{