Change the default error trapping. |
By default, any error is trapped and shown the end user. This is great for development, but not so great for production. To change this behavior, edit the webroot/Application.cfm and find the onError function.
Change
<cfset super.OnError(argumentCollection=arguments) /> |
Becomes
<cfset var machineName = createObject("java", "java.net.InetAddress").localhost.getHostName() /> <cfif machinename contains("<yourservername>")> <cfsavecontent variable="errordump"> <cfoutput> <h3>Error Overview</h3> <pre> Machine: #variables.machineName# Message: #arguments.exception.Message# Browser: #cgi.HTTP_USER_AGENT# DateTime: #now()# Host: #cgi.HTTP_HOST# HTTPReferer: #cgi.HTTP_Referer# QueryString: #cgi.Query_String# RemoteAddress: #cgi.Remote_Addr# </pre> <h3>Root Cause</h3> <cfdump var="#arguments.exception#" label="Error Diagnostics"> </cfoutput> </cfsavecontent> <cfmail from="<validemail>" to="<validemail>" subject="ERROR - <sitename>" type="html"> <cfoutput> #errordump# </cfoutput> </cfmail> <cfelse> <cfset super.OnError(argumentCollection=arguments) /> </cfif> |