【发布时间】:2018-05-16 14:52:11
【问题描述】:
我遇到了一个问题,我的 onError 方法在我的 application.cfc 文件中不再有效。该程序昨天捕获错误并正确显示 error.cfm,但现在我收到 500 错误。我的经理昨天可能更改了文件中的一些内容,但我们似乎重新创建了它,但没有解决任何问题。
我目前使用 onError,但我尝试了 cferror。使用 cferror 甚至无法加载数据输入表单。
代码如下。 onError 被阻止,因为我用 cferror 代码显示它。如果你想使用它,只需删除 cferror 和 blocks 就会出现 onError:
<!--- this component controls the application's global settings / event
handlers and maintains user sessions --->
<cfcomponent>
<!--- define some basic settings --->
<cfset this.name = "QualityDataPortal" />
<cfset this.sessionManagement = "yes" />
<cfset this.setClientCookies = "no" />
<cfset this.loginStorage = "session" />
<!--- this function is triggered when our application is initialized --->
<cffunction name="onApplicationStart" access="public" returntype="boolean" output="no">
<!--- define application variables --->
<cfset application.dataSource = 'quality' />
<!--- return out --->
<cfreturn true />
</cffunction>
<cferror
template="error.cfm"
type="exception"
mailTo="Generic@org.edu" />
<!--- <!--- this function is triggered when coldfusion encounters an error --->
<cffunction name="onError" access="public" returntype="void" output="no">
<cfargument name="exception" required="yes">
<cfargument name="eventname" type="string" required="yes">
<!--- send a dump of the error via email --->
<cfmail from="QDP@org.edu" to="Generic@org.edu" subject="Quality Data Portal Error Encountered" type="html">
<cfoutput>
The following error was encountered on #dateformat(now(), 'dddd mmmm dd, yyyy')# at #timeformat(now(), 'hh:mm:ss tt')#<br /><br />
<cfdump var="#arguments.exception#">
<cftry><cfdump var="#arguments#"><cfcatch></cfcatch></cftry>
<cfdump var="#form#">
<cfdump var="#session#">
<cfdump var="#cgi#">
</cfoutput>
</cfmail>
<!--- alert the user that an error has been encountered --->
<cflocation url="error.cfm" addtoken="no">
<cfabort />
</cffunction> --->
<!--- this function is triggered when coldfusion receives a request for a template it cannot locate --->
<cffunction name="onMissingTemplate" access="public" returntype="void" output="no">
<cfargument name="targetPage" type="string" required="yes">
<!--- alert the user that the page they requested could not be found --->
<cflocation url="404.cfm" addtoken="no">
<cfabort />
<!--- return out --->
<cfreturn />
</cffunction>
</cfcomponent>
【问题讨论】:
-
500个错误是http,不是coldfusion
-
我怀疑您的错误处理程序代码引发了错误。取出
<cferror >标签,你不需要它。清空您的onError函数以至少发送电子邮件。假设可行,开始重新添加代码,直到它再次失败。然后修复它。
标签: javascript html server coldfusion