У меня проблема с тем, что мой метод onError больше не работает в моем файле application.cfc. Вчера программа ловила ошибки и правильно отображала error.cfm, но теперь я просто получаю 500 ошибок. Возможно, мой менеджер вчера изменил пару вещей в файле, но мы, кажется, воссоздали его, и это ничего не исправило.
В настоящее время я использую onError, но я попробовал cferror. С cferror форма ввода данных даже не загружается.
Код ниже. Ошибка onError заблокирована, потому что я показываю ее с кодом cferror. Просто удалите cferror и блоки, если вы хотите его использовать, будет 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>