<!--- Enable site wide error handling. When an error is found, the details of the error will be sent to error_process.cfm --->
<cferror type="request" template="error_process.cfm" mailto="">


<!--- The page template specified in the cferror tag can not contain any cf code. If there was an error with the code on that page, you would get into and endless loop of errors --->

<!--- Since we cant use cfmail, we will pass these varibles to another page. The variables will provide us with the details of the error --->
<form name="error_report" method="post" action="error.cfm">
   <input type=
"hidden" name="diagnostics" value="#error.Diagnostics#">
   <input type=
"hidden" name="browser" value="#error.Browser#">
   <input type=
"hidden" name="remoteaddress" value="#error.RemoteAddress#">
   <input type=
"hidden" name="httpreferer" value="#error.HTTPReferer#">
   <input type=
"hidden" name="template" value="#error.Template#">
   <input type=
"hidden" name="querystring" value="#error.QueryString#">

<!--- Javascript to pass variables to next page --->
<script language="JavaScript">


<!--- Email Error Message --->
<cfmail from="" to="" subject="Bug Report">

Oops! An error has occurred.</title>


<p align="center"><strong>We're Sorry! An error has occurred.</strong><br>
The details of this error have been emailed to the web site administrator.<br>
Please <a href="index.cfm">click here</a> to return to the homepage.</p>

About This Tutorial
Author: Jason Rockenbach
Skill Level: Intermediate 
Platforms Tested: CF4,CF5,CFMX
Total Views: 93,154
Submission Date: March 31, 2003
Last Update Date: June 05, 2009
All Tutorials By This Autor: 1
Discuss This Tutorial
  • I've solved this by: 1. ensuring I have html and body tags aroudn the hidden form (this affects firefox) 2. making sure the comment lines () are present in the script tag

  • use This is what I do: ... ... ... The following errors were encountered on #dateformat(now(),"MM/DD/YYYY")# at #timeformat(now(),"HH:MM tt")# The above will trap any any errors in the clause, and e-mail them in the clause. The is a VERY COOL tool to use to debug any issues. Provides more information then the traditional debug tool cf throws on the screen.

  • If you get a blank error.cfm page you may want to look and see if you have enablecfoutputonly="yes" in your application.cfm page. If so set enablecfoutputonly = "no" at the top of error.cfm so that the page will display.

  • I have solved this problem in the past by adding a radio or check box to the form and use css to hide it because you don't entend for the user to click it. You can put a div around your form and had that as well.. Works for me..

  • The CF code appears to be okay, the automatic submit for the error_process.cfm page is the problem. If I replace that code and have the error_process.cfm page display with an actual submit button, things work fine. A click of the submit button will display the error.cfm page and email the contents. However, that defeats the goal of an automated process. You don't really want users to have to click a button to let you know an error occurred. To get the auto-submit to work you may need to call it with a function that fires with the onLoad event in the tag of the error_process.cfm page. This won't work all the time, but will work for errors that occur early enough to be captured by the onLoad event. Try Modify a tag to the following: That seems to get it working as intended. Not full proof, but does most of what is expected.

  • Can you provide me with more details? What exactly doesnt work for you? I use this on at least 5 different web sites and it does a great job of catching all errors.

  • This code doesnt seem to work for me either.

  • The code does work, I have used it on CF5 and CFMX. Have you tried it out? What were your results?

  • Is there some tweak that will make this code work??

  • This doesn't work. The ability to fire a submit action without the user initiating it has been deprecated for security reasons.


Sponsored By...
Mobile App Development (IOS, Android, Cordova, Phonegap, Objective-C, Java) - Austin, Texas Mobile Apps - Touch512, LLC.