Getting error message - onError undefined - even though onError is handling the error

I'm setting up a new app in CF 10, and have set up my application.cfc. I created a test page that calls onError() manually, as a test. Like the title says, I get a message saying "onError is not defined", but onError() itself is handling this error. I know this because I have it output a string to indicate that it has fired.
Also, I'm trying to test onError() by intentionally not closing a tag and calling the page. onError() won't fire here; instead I get the standard ColdFusion error grey box.
Any help on these is much appreciated.

Xophe99 wrote:
... I believe that an instance of Application.cfc is instantiated when the application starts, else how could the event handlers listen and fire when they should?
That is generally true. However, that is only part of a process that the ColdFusion engine does under the hood, beyond your control. However, the way to manually call a function is to use an object that is created or is available in the current page context. This brings us to the next point.
Also, you can call Application.cfc's functions on all cfm pages via the variables scope:
http://www.bennadel.com/blog/385-Application-cfc-Scoped-Functions-Are- Stored-In-Page-VARIABLES-Scope.htm
That is also true. As ColdFusion stores methods in the variables scope, and practically 'includes' Application.cfc in the CFM page request, calling variables.onError() would work. So, too, would appObj.onError(), where appObj is an object created from Application.cfc.
However, these are what you could call undocumented features. They occur by accident rather than by design. It would, for example, be inadvisable to use them in critical software.
A car can run with the doors open, with no steering wheel and with the driver outside. We all know what happens next. It usually involves the already heavily strained health services.

Similar Messages

Maybe you are looking for