Here's something I have used for a while and just tweaked for each project - I never got around to making this a truly dynamic custom tag that I could just plug into an app.... I guess I should but I'm just to lazy :)


Hope this helps for some ideas.


<cfsilent>
<!--- ===================================================================================================== --->
<!--- NAME:                                        --->
<!---   customErrTrap                                 --->
<!---                                           --->
<!--- PURPOSE:                                        --->
<!---   Provide a single template for processing (CFTRY/CFCATCH) errors with the ability to:     --->
<!---    1.  Send an email with detailed error information to 1 or more persons (Default Option)         --->
<!---           And / Or                              --->
<!---       2.  Abort after processing and display minimal error information to the customer              --->
<!---           with the site administrator's email address as a contact if they wish to report anything. --->
<!---                                           --->
<!---           IF YOU DO NOT SELECT THIS OPTION IT IS UPON THE DEVELOPER TO HANDLE THE ERROR GRACEFULLY    --->
<!---           WITHIN THEIR CODE.                           --->
<!---                                           --->
<!--- NOTES:                                       --->
<!---   This tag must be between <cfcatch></cfcatch> to function properly.         --->
<!---   This tag assumes, if you are passing email addresses, they are valid.  No validation at this time. --->
<!---   (Possibility to check for valid email addresses [multiple listing] @ a future date.)                --->
<!---                                           --->
<!--- USAGE:                                       --->
<!---   Default Option #1 above:                                  --->
<!---  <cf_customErrTrap>                            --->
<!---   Selecting Options:                                    --->
<!---       <cf_customErrTrap                                --->
<!---        errMail="0/1"                               --->
<!---        errMailTo=" [EMAIL PROTECTED]"                          --->
<!---           errMailSubject="Hey there was a problem"                      --->
<!---           errAbort="0/1"                            --->
<!---           errSiteAdmin=" [EMAIL PROTECTED]"              --->
<!---   errPath="#getCurrentTemplatePath()#">                      --->
<!---                                           --->
<!--- ATTRIBUTES:                                     --->
<!---   errMail    : {Optional} (Default = On) Send Email with error info? [0=Off / 1=On]              --->
<!---   errMailTo       : {Optional} Who is the Email to?               --->
<!---   errMailSubject  : {Optional} What is the Email subject?              --->
<!---   errAbort        : {Optional} (Default = Off) Abort after processing & display error? [0=Off / 1=On] --->
<!---   errSiteAdmin    : {Optional} Email address to display when we 'abort' and display the error?     --->
<!---   errPath   : {Optional} Path and template name throwing error         --->
<!--  errDeveloper : {Optional} Email address to send error email to.  This would be used for   --->
<!---          Development / Testing and WILL OVERRIDE the errMailTo attribute  --->
<!---          if used.                --->
<!---                                           --->
<!--- AUTHOR:                                       --->
<!---  Steven Semrau ( [EMAIL PROTECTED])                     --->
<!---                                           --->
<!--- DATE:                                        --->
<!---   Tuesday, April 02, 2002                             --->
<!---                                           --->
<!--- MODIFICATION LOG:                                  --->
<!---  DATE     AUTHOR      NOTES                         --->
<!---  ====     ======      ======================================================================= --->
<!---   03/22/2004 S.Semrau  Modified for use with BRAC Application         --->
<!---  03/30/2004  S.Semrau  Added Local (variables.xxx) and Application.xxx variables to the email --->
<!---         output.  Also added SQLState and NativeErrorCode cfcatch variables to  --->
<!---         the email output.              --->
<!--- ===================================================================================================== --->
</cfsilent>
<!--- Copy Application scoped variables to request scope variables to avoid unnecessary CFLOCKs --->
<cflock timeout="5" throwontimeout="no" type="readonly" scope="application">
<cfset request.application = duplicate(application)>
</cflock>
<!--- Copy session scoped variables to request scope variables to avoid unnecessary CFLOCKs --->
<cflock timeout="5" throwontimeout="no" type="readonly" scope="session">
<cfset request.session = duplicate(session)>
</cflock>
<!--- ############ --->
<!--- Set Defaults --->
<!--- ############ --->
<cfparam name="errMail" type="numeric" default="1">
<cfparam name="errMailFrom" type="string" default="""#request.session.systemdescription#"" < [EMAIL PROTECTED]>">
<cfparam name="errMailTo" type="string" default="#request.application.errorEmail#">
<cfparam name="errMailSubject" type="string" default="A #caller.cfcatch.type# error has been encountered on the (#cgi.server_name#) server.">
<cfparam name="errAbort" type="numeric" default="0">
<cfparam name="errSiteAdmin" type="string" default=" [EMAIL PROTECTED]">
<cfparam name="errPath" type="string" default="No template path provided to custom error tag.">
<!--- Check and set any attributes passed by the custom tag --->
<cfif isDefined("attributes.errMail") AND len(trim(attributes.errMail)) GT 0>
<cfset variables.errMail = attributes.errMail>
</cfif>
<cfif isDefined("attributes.errMailTo") AND len(trim(attributes.errMailTo)) GT 0>
<cfset variables.errMailTo = attributes.errMailTo>
</cfif>
<cfif isDefined("attributes.errMailSubject") AND len(trim(attributes.errMailSubject)) GT 0>
<cfset variables.errMailSubject = attributes.errMailSubject>
</cfif>
<cfif isDefined("attributes.errAbort") AND len(trim(attributes.errAbort)) GT 0>
<cfset variables.errAbort = attributes.errAbort>
</cfif>
<cfif isDefined("attributes.errSiteAdmin") AND len(trim(attributes.errSiteAdmin)) GT 0>
<cfset variables.errSiteAdmin = attributes.errSiteAdmin>
</cfif>
<cfif isDefined("attributes.errPath") AND len(trim(attributes.errPath)) GT 0>
<cfset variables.errPath = attributes.errPath>
</cfif>
<cfif isDefined("attributes.errDeveloper") AND len(trim(attributes.errDeveloper)) GT 0>
<cfset varilabes.errMailTo = attributes.errDeveloper>
</cfif>
<!--- Test to make sure we are within a CFTRY / CFCATCH --->
<cfif isDefined("caller.cfcatch.type") AND isDefined("caller.cfcatch.message") AND isDefined("caller.cfcatch.detail")>
<!--- Are we going to email this error? --->
<cfif variables.errMail EQ 1>
  <!--- Single Quotes are used in the FROM address below because of the format we are using with email address --->
  <cfmail to="#variables.errMailTo#" from='#variables.errMailFrom#' subject="#variables.errMailSubject#" type="HTML">
  <div align="center">
   Help Desk Notice:  An error was encountered on the (#cgi.server_name#) #session.systemdescription# server.
  </div>
  <p>&nbsp;</p>
  <table border="0" cellspacing="0" cellpadding="0" align="center">
   <tr><th>User Information</th></tr>
   <tr>
    <td>
     <table border="1" cellspacing="2" cellpadding="2" align="center" bgcolor="E5E5E5">
      <tr><td>Usersid:&nbsp;#request.session.usersid#</td><td>UserLogin:  #request.session.userlogin#</td></tr>
     </table>
    </td>
   </tr>
   <tr><td colspan="2">&nbsp;</td></tr>
   <tr><th>Offending Template</th></tr>
   <tr>
    <td>
     <table border="1" cellspacing="0" cellpadding="0" align="center" bgcolor="E5E5E5">
      <tr><td>#variables.errPath#</td></tr>
     </table>
    </td>
   </tr>
   <tr><td colspan="2">&nbsp;</td></tr>
   <tr><th>Error Information</th></tr>
   <tr>
    <td>
     <table border="1" cellspacing="0" cellpadding="0" align="center" bgcolor="E5E5E5">
      <tr><th align="left" valign="top" nowrap>Type:</th><td>#caller.cfcatch.type#</td></tr>
      <tr><th align="left" valign="top" nowrap>Page:</th><td>#caller.cgi.path_translated#</td></tr>
      <tr><th align="left" valign="top" nowrap>Message:</th><td>#caller.cfcatch.message#</td></tr>
      <tr><th align="left" valign="top" nowrap>Detail:</th><td>#caller.cfcatch.detail#</td></tr>
     </table>
    </td>
   </tr>
   <tr><td colspan="2">&nbsp;</td></tr>
   <tr><th>Additional Information for Programmers:</th></tr>
  </table>
  <br><br>Dump of all CGI Variables:<br><cfdump var="#cgi#">
  <br><br>Dump of all URL Variables:<br><cfdump var="#url#">
  <br><br>Dump of all FORM Variables:<br><cfdump var="#form#">
  <br><br>Dump of all SESSION Variables:<br><cfdump var="#session#">
  <br><br>Dump of all APPLICATION Variables:<br><cfdump var="#application#">
  </cfmail>
</cfif>
<!--- If we are 'aborting', display appropriate information to the user. --->
<cfif attributes.errAbort EQ 1>
  <cfoutput>
   <h4 align="center">An error has been encountered with the #request.session.systemdescription# Application.</h4>
   <!--- If we sent email, notify customer --->
   <cfif variables.errMail EQ 1>
    <div align="center">Detailed information regarding the problem has been emailed to the BRAC Help Desk personnel.</div>
   </cfif>
   <p align="center">
    Please do a screen shot of this page and attach it to an email, with any additional information you may have, addressed to the Help Desk at<br><br>
    (<a href="" [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ).

mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>).<br><br>
    Please exit the Application / close your browser.  You may try to enter the #request.session.systemdescription# Application again and continue working,<br>
    however, please note that you may encounter the same error again until it is addressed by the Help Desk.
   </p>
     </cfoutput>
  <cfabort>
</cfif>
</cfif>

Steven Semrau
SRA International
http://www.sra.com

-----Original Message-----
From: Tony Weeg [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 11, 2004 4:04 PM
To: CF-Talk
Subject: RE: good error.cfm template

yeah, that's what I have begun to do as well :)

but, was just wondering what people thought of, and what they did...

any one else have a cool error.cfm template?

tony

-----Original Message-----
From: Matt Robertson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 11, 2004 3:55 PM
To: CF-Talk
Subject: Re: good error.cfm template

Tony,

I've gone to just CFDUMPing out every scope you can think of.  It makes for
a big, uh... dump, and usually its more info than I need, but doing it this
way has proven invaluable to me on many occasions.  The emails tend to be
about 110k to 180k, and if you are doing something like holding large
queries in memory you'll want to consider what that will do to the size of
the email generated.

Another thing you can do is write this stuff to a text file.  That will
mitigate or solve the large query issue, and will also take care of another
issue: if you hold secure data in memory you shouldn't email it to yourself.

--
-------------------------------------------
Matt Robertson,     [EMAIL PROTECTED]
MSB Designs, Inc. http://mysecretbase.com
-------------------------------------------

--
  _____  

[ Todays  <http://www.houseoffusion.com/lists.cfm/link=t:4> Threads] [ This  <http://www.houseoffusion.com/lists.cfm/link=i:4:162910> Message] [ Subscription <http://www.houseoffusion.com/lists.cfm/link=s:4> ] [ Fast  <http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=6638.6038.4> Unsubscribe] [ User  <http://www.houseoffusion.com/signin/> Settings]
  _____  

<http://www.houseoffusion.com/banners/view.cfm?bannerid=37>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to