Brian,
Just a couple of questions for clarification. Are you using the
handleException() plugin point in your other applications? And if you
are, are you calling arguments.eventContext.getCurrentEvent()?
Here's the low down. In the preProcess() plugin point, we all know that
the event processing hasn't started yet and we need to get the 1st event
of the in the queue using getNextEvent().
Now, in the handleException point() -- there is an cart before the horse
situation when that point is called before event processing begins (as
in the case you illustrate). So you need to do something like this in
your handleException() point (excuse my brevity in code by leaving off
attributes):
<cffunction name="handleException">
<cfargument name="eventContext"/>
<cfset var event = "" />
<cfset var missingEvent = "" />
<cfif arguments.eventContext.hasCurrentEvent()>
<cfset event = arguments.eventContext.getCurrentEvent() />
<cfelse>
<cfset event = arguments.eventContext.getNextEvent() />
</cfif>
<!--- If it is due to the a missing event args and you'll want the
missing event as well, you need to do: --->
<cfif arguments.exception.getType() EQ
"MachII.framework.EventHandlerNotDefined">
<cfset missingEvent = event.getArg("missingEvent") />
</cfif>
</cffunction>
The conundrum is that handleException (unlike all other plugin points)
can occurs before event processing has begun and while events are being
processed. So it is a little bit special because of that.
There is a ticket #385 that brings up the issue that exception that
occur in the preProcess and postProcess (and I've mentioned that
handleException is another pinch point).
We could probably use a bit of spit and polish on making the
handleException() plugin point easier to work with (illustrated above).
If you have any ideas on how to do that, feel free to suggest them --
I'm all for making it a snap to deal with as long as we can maintain
backwards compatibility. Maybe it's as simple as adding a third
argument called "currentOrNextEvent".
Best,
.Peter
P.s. If you feel so inclined, I encourage you to use my email here as a
basis for creating a new FAQ on the subject. We have one for getting
the event during the preProcess point -- sounds like we need for
exception handling. Any help is most appreciated.
Brian Klaas said the following on 11/12/2009 01:42 PM: