[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-user
Subject:    Re: EventCartridge and handlers...
From:       "Tim Joyce" <tim () hoop ! co ! uk>
Date:       2001-04-20 11:37:06
[Download RAW message or body]

Geir,

> 1) I put in whatever came to mind in ASTMethod and
> MethodExceptionEventHandler.  Tim, for example, has some experience and
> need - so whatever needs to be changed should be.

ok, below are some diffs, that allow MethodExceptions to be passedback.  i
hope this helps.

cheers

timj


diff -r1.15 ASTMethod.java
227a228,231
>         catch( MethodInvocationException mie )
>         {
>             throw mie;
>         }

diff -r1.6 PropertyExecutor.java
59a60
> import org.apache.velocity.runtime.Runtime;
61a63
> import org.apache.velocity.context.EventCartridge;
141,142c143,147
<              *  the method we invoked threw an exception.
<              *  package and pass it up
---
>              *  In the event that the invocation of the method
>              *  itself throws an exception, we want to catch that
>              *  wrap it, and throw.  We don't log here as we want to
figure
>              *  out which reference threw the exception, so do that
>              *  above
145,147c150,180
<             throw  new MethodInvocationException(
<                 "Invocation of method '" + methodUsed + "'"
<                 + " in  " + o.getClass()
---
>             EventCartridge ec = context.getEventCartridge();
>
>             /*
>              *  if we have an event cartridge, see if it wants to veto
>              *  also, let non-Exception Throwables go...
>              */
>
>             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 "
>                         + e.getClass(), e, methodUsed );
>                 }
>             }
>             else
>             {
>                 /*
>                  * no event cartridge to override. Just throw
>                  */
>
>                 throw new MethodInvocationException(
>                 "Invocation of method '"
>                 + methodUsed + "' in  " + o.getClass()
150a184
>             }

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic