1 / 12

Dynamic Debug Output and Error Handling in CF5 and CFMX

Dynamic Debug Output and Error Handling in CF5 and CFMX. November 12, 2002 By Douglas M. Smith Application Architect for Teratech, Inc. Reasons for this Presentation.

dannon
Download Presentation

Dynamic Debug Output and Error Handling in CF5 and CFMX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dynamic Debug Output and Error Handling in CF5 and CFMX November 12, 2002 By Douglas M. Smith Application Architect for Teratech, Inc.

  2. Reasons for this Presentation • I wanted to see the web site exactly as the client would see it, yet at the same time, I wanted developer’s to see debug and error output. • I wanted to allow developers to view debug and error info, but hide it from regular users. • I wanted to embed custom debug output in my code during development, and keep it available for later testing and bug fixing, without having to comment code in and out. • I wanted a mechanism to turn dynamically turn on/off the standard CF debug output display (at the bottom of each page) • For security reasons, I only wanted the developer to be able to see or turn on error or debug output.

  3. Code in Application.cfm • Sets variables that are used in <CFERROR> and <CFCATCH> error handling templates • Sets variables that are used to control access to debug output. Basically, these are lists of IP addresses, similar to how the CF Admin controls access to debug output. • Has code to set CLIENT.DEBUG variable, which is the main switch variable. • Sets the <CFERROR> template.

  4. Code in OnRequestEnd.cfm • Code to turn on/off standard CF debug output • Code to turn on/off custom debug output • In CF5, use MOD_DISPLAY_VARIABLES.cfm • In CFMX, don’t need this. Can use settings in CFADMIN, or just use CFDUMP

  5. Code in <CFERROR> Template Usage: <cferror type="exception" template="error_exception.cfm"> • Code to email any error to web master • Code to turn off email, and display error, if desired by developer • In CFMX, code to display error context

  6. Custom Debug Output Code Put code like this this wherever you want custom debug output: <cfif Client.Debug> Your custom debug output. </cfif>

  7. Code in <CFCATCH> Template Usage: <CFCATCH><CFINCLUDE template=“error_catch.cfm”> </cfcatch> • Very similar to CFERROR • Code to email any error to web master • Code to turn off email, and display error, if desired by developer • In CFMX, code to display error context

  8. “Gotchas” • Code in Application.cfm before the <cferror> statement is not caught by anything, so make sure it is bug-free. • Error handlers must be tested and be error free before they will work. This is especially important in CFMX. • If there is an error in the error_handler, you won’t get your email. Generate an error using <cfabort showerror="x"> to make sure you are getting your error emails.

  9. More “Gotchas” • Compilation errors in normal code are not caught by CFERROR handler. These are displayed to standard error output. Only runtime errors are caught. • Compilation errors in CFERROR handler itself under CFMX are not reported at all! It simply appears like the <CFERROR> tag does not work. You will get default debug output to the screen, and you will loose error handling benefits.

  10. New Features in CFMX • <CFDUMP> is awesome! • TagContext is now available in <CFERROR> as well as in CFCATCH • Standard debug output has actual line numbers, and error in bold. Cool, but feature is lost when using error or cfcatch variables!

  11. Questions?

  12. Contact Info Douglas M. Smith Douglas@teratech.com Download this presentation from: http://www.cfug-md.org/

More Related