Abort is an Error
I've been trying to use application.cfc more in my work and I've found another little 'gotcha'. Lets walk through this one step by step. A LOT of people use a CFABORT in their code to control the flow of their page. The logical assumption is that when the CFABORT is called, the page stops dead in its tracks. If the showerror attribute is set inside the CFABORT then an exception error is thrown. This acts like a slightly cut down version of the CFTHROW tag. But when you have not set the showerror attribute, you don't expect an error, right?
Guess what. There is a specific situation where the use of a simple CFABORT will be considered an error and this is (or should be) a common situation. When you have an application.cfc with an onRequest() and an onError() method and the template being called by the onRequest() has a CFABORT in it, the onError will detect that usage of the CFABORT as an error.
The error message will be supremely unhelpful as it simply says that there's an error in the onRequest method of the application.cfc. You have to look through the stack trace and tag context to see that the error was on a specific line and the last tag to fire was a CFABORT. But even then, you would not think this was the problem as there is no logical reason for it to be the problem.
The solution is to either not use CFABORT for page control when using these two methods or to remove one of those methods from your application.cfc. Either one can be removed and the error is gone.
So what has this taught me? Not that there is a strange combination of code in ColdFusion. Not that there is a potential bug in how onError handles error events. This has taught me that there are just not a lot of people using the application.cfc template. If there were, this problem would have appeared much earlier. Maybe it has and I missed it, but somehow I doubt that.


<cfif arguments.exception.rootCause eq "coldfusion.runtime.AbortException">
<cfreturn/>
</cfif>
<cfif arguments.exception.rootCause eq "coldfusion.runtime.AbortException">
<cfreturn/>
</cfif>