refactor cferror tag to application.cfc's onError()

﹥>﹥吖頭↗ 提交于 2019-12-11 11:44:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!