Georgetown University Home  |  A-Z Index  |  Contents  |  Directories  |  Search 
 UIS » Web development » Web application development  » ColdFusion » Custom tags
 cf_ErrorTrapping


Description

This tag provides centralized, but customizable, ColdFusion error trapping. It catches all ColdFusion exception errors, including custom cfthrow errors, but does not catch form validation errors.

Required Attributes

  1. errorHeaderPath
    This attribute contains the path for the application header. It should be a relative path from the root of the web server.
    example: errorHeaderPath="uis/web/coldfusion/header.cfm"

  2. errorFooterPath
    This attribute contains the path for the application footer. It should be a relative path from the root of the web server.
    example: errorFooterPath="uis/web/coldfusion/footer.cfm"

  3. errorEmailAddress
    This attribute contains the e-mail address of the site administrator. All errors will automatically be sent to this e-mail address unless the user producing the error has an IP address listed in the optional errorAdminNetIDs attribute, or a NetID listed in the optional errorAdminNetIDs attribute.
    example: errorEmailAddress="netid@georgetown.edu"

Optional Attributes

  1. errorEmailSubject
    This optional attribute can contain a subject for the e-mail that will be sent to the administrator when there are errors.
    example: errorEmailSubject="UIS web accounts application error"

  2. errorCustomMessage
    This optional attribute can contain html text that will display for users after the default error message with a short description of the problem has been displayed.
    example: errorCustomMessage="<p>If you feel that this error is due to a consistent problem with this web site, please contact the site administrator at <a href="netid@georgetown.edu">netid@georgetown.edu.</p><p>We apologize for any inconvenience.</p>"

  3. errorAdminIPs
    This optional attribute allows you to specify the IP address(es) of any administrators for the site. If an error is produced by an IP address in the list, the full error details will display instead of the short public message, and the e-mail will not be sent. If you have multiple IP addresses, separate them with commas and do not use any spaces.
    example: errorAdminIPs="141.161.100.100,141.161.100.200"

  4. errorAdminNetIDs
    This optional attribute allows you to specify the NetID(s) of any administrators for the site. This will only work if the site is NetID restricted. If an error is produced by a NetID in the list, the full error details will display instead of the short public message, and the e-mail will not be sent. If you have multiple NetIDs, separate them with commas and do not use any spaces.
    example: errorAdminNetIDs="hoyaj,hoyaj2"

  5. errorShowFormValues
    This optional attribute can specifies whether form values are displayed in the full error message that is viewed by the administrator (if errorAdminIPs or errorAdminNetIDs are used) or e-mailed to the administrator. Possible values are True and False, and the default is False.
    example: errorShowFormValues="True"

Usage

This tag needs to be placed in the Application.cfm file for the application. It should be placed after any application of session variables are set, but before any other code.

The tag does not cover form validation errors, so if you wish to catch these, you will still need to include a cferror tag for this: <cferror type="Validation" template="validation_error.cfm">.

When using cf_ErrorTrapping you do not need to use <cftry><cfcatch ...></cfcatch></cftry> and including this in your application may lead to problems.

You can still catch custom errors using <cfthrow> For example, the following code will still work:

<cfif not IsDefined("url.ID") or not ISnumeric(url.ID)>
<cfthrow type="custom" message="No ID was specified">
</cfif>

Example:

<cf_ErrorTrapping
errorHeaderPath="uis/web/coldfusion/header.cfm"
ErrorFooterPath="uis/web/coldfusion/footer.cfm"
errorEmailAddress="netid@georgetown.edu"
errorEmailSubject="UIS web accounts application error"
errorCustomMessage="<p>If you feel that this error is due to a consistent problem with this web site, please contact the site administrator at <a href="netid@georgetown.edu">netid@georgetown.edu</a>.</p><p>We apologize for any inconvenience.</p>"
errorAdminIPs="141.161.100.100,141.161.100.200"
errorAdminNetIDs="hoyaj,hoyaj2"
errorShowFormValues="True">

 
 Georgetown University Home  |  A-Z Index  |  Contents  |  Directories  |  Search 
© Copyright 2001, Georgetown University