WolfShade, what is in your onRequest() method? If you pass the nonexistent template as an argument of onRequest(), but don't force navigation to a different page, it would still throw an error. Do you have a FileExists() check in onRequest() to verify the template exists prior to including it?
Hi, Carl Von Stetten!
My onRequest() method is bare-bones:
<cffunction name="onRequest" returntype="void"> <cfargument name="thePage" type="string" required="true" /> <cfinclude template="#arguments.thePage#" /> </cffunction>
The onError() method is triggered, which redirects to my errors.cfm page, and it _should_ stop processing after displaying errors.cfm.
I've seen several examples online for onRequest() and onError(), and I've never seen one include a FileExists() conditional. Is that common??
1 person found this helpful
From what I can tell, your onMissingTemplate trap is probably working but your code within the event is retriggering the same error. I'm not sure your goal. I usually create an error.cfm template and simply include that module:
<cffunction name="onMissingTemplate" returntype="boolean" output="false" >
<cfargument name="template" type="string" required="true" />
<cfinclude template="error.cfm" />
I'm not 100% certain if the cfabort call is required but it does not seem to hurt. <cfreturn false /> probably does the same thing.
<cfreturn false /> did not prevent the CF error message from appearing, but <cfabort> did. I'm a bit leery to use <cfabort>, because I don't know if that will prevent other things from happening; however, at this point, I'm willing to give it a shot in production.
Thanks, Steve Sommers!
I try to limit my use of cfabort but for something like this I would use it (obviously since that was my example). If you have an onRequestEnd (or whatever it's named), cfabort does prevent it from being called. I found this out the hard way when my onRequestStart was allocating some memory and my onRequestEnd was releasing it -- upon several cfabort calls, I was out of memory and this was a tricky one to find.