I am currently trying to capture all errors in my application by including the following code in Application.cfc:
<cffunction name="onError">
<!--- The onError method gets two arguments:
An exception structure, which is identical to a cfcatch variable.
The name of the Application.cfc method, if any, in which the error
happened. --->
<cfargument name="Except" required=true/>
<cfargument type="String" name = "EventName" required=true/>
<!--- Log all errors in an application-specific log file. --->
<cflog file="#THIS.NAME#" type="error" text="Event Name: #Eventname#" >
<cflog file="#THIS.NAME#" type="error" text="Message: #Except.message#">
<!--- Throw validation errors to ColdFusion for handling. --->
<cfif Find("coldfusion.filter.FormValidationException", Arguments.Except.StackTrace)>
<cfthrow object="#Except#">
<cfelse>
<cfoutput>
<h1>#Eventname#</h1>
</cfoutput>
<cfdump var="#Except#">
</cfif>
</cffunction>
Some of that is borrowed from other examples I have seen (which I don't fully understand). I ultimately want to show some kind of graceful error page to solicit feedback from the user and then log/email the error. This seems to catch a lot of errors, but not all. I don't want to use try/catch everywhere if I don't have to either. Any suggestions?
There is also an overall ColdFusion error handler that you can define in the ColdFusion administrator. Under the Server Settings > Settings, scroll down to the bottom and set the option for "Site-wide Error Handler".
Check this in the docs as well About error handling in ColdFusion