问题
How to translate
<cferror type="EXCEPTION" template="ErrorTemplate.cfm">
to an onError()
function for Application.cfc? Notice that cferror create a var error
struct for the template. Is there a quick and easy way to create the same error struct? How to pass that into ErrorTemplate.cfm using <cfinclude>
?
I know onRequest()
shares the variable scope with the target page, but does onError share variables scope too? If not, what shall I do? Stick it to the Form
scope?
Thank you
回答1:
According to http://livedocs.adobe.com/coldfusion/8/htmldocs/appFramework_15.html
Consider replacing cferror tags with an onError event method. If you do not do so, put the cferror tags in the CFC initialization code.
According to http://www.coldfusionjedi.com/index.cfm/2007/12/5/The-Complete-Guide-to-Adding-Error-Handling-to-Your-ColdFusion-Application
What if you are using Application.cfc? Well one thing to remember is that you can just as easily put CFERROR tags inside your Application.cfc file. That is allowed, and I've done that before.
回答2:
Why would you not just use onError in App.cfc to display a "Sorry and error occurred, we are working on it" type page?
来源:https://stackoverflow.com/questions/7101485/refactor-cferror-tag-to-application-cfcs-onerror