| By Charlie Arehart | Article Rating: |
|
| September 18, 2003 12:00 AM EDT | Reads: |
8,312 |
One of the great new features in 4.5 is a new form of global exception handling. Whereas 4.0 introduced CFTRY/CFCATCH to wrap around a segment of code to be tested and acted upon in case of error, we were still limited to the aged CFERROR tag to trap general errors.
The benefit of CFERROR is that you get to create a page with the layout and background colors to suit you and your organization's preferences, rather than the unadorned white page with black text that is normally displayed when a CF error is encountered.
Unfortunately, until 4.5, you could only use HTML on this error handling page. No CFML. There was a presumed CFOUTPUT open, but the only available variables were those holding information about the error.
You couldn't trigger an e-mail with CFMAIL, nor could you log the error in a database. These limitations kept many from bothering, which is too bad because end users were stuck with the simple "spit-up" on the screen that's normally shown with CF errors.
Now, in 4.5, there is a new option for CFERROR, called TYPE=EXCEPTION, which allows you to specify an error page to handle processing of otherwise untrapped errors. It directs control to the named page and that page is allowed to do full CF processing, unlike the older CFERROR TYPE=REQUEST.
New Site-Wide Error Handler
Also, in 4.5, there is a new option to specify (in the CF Administrator) a site-wide error handling template. Think of this as handling errors when the CFERROR mentioned above is not used. It takes the user to the specified page which, again, has full access to CF processing, including creating e-mail with CFMAIL, creating a log file in a database, and more.
Charlie Arehart
Allaire Certified Trainer
Course Developer
Fig Leaf Software
Published September 18, 2003 Reads 8,312
Copyright © 2003 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Charlie Arehart
A veteran ColdFusion developer since 1997, Charlie Arehart is a long-time contributor to the community and a recognized Adobe Community Expert. He's a certified Advanced CF Developer and Instructor for CF 4/5/6/7 and served as tech editor of CFDJ until 2003. Now an independent contractor (carehart.org) living in Alpharetta, GA, Charlie provides high-level troubleshooting/tuning assistance and training/mentoring for CF teams. He helps run the Online ColdFusion Meetup (coldfusionmeetup.com, an online CF user group), is a contributor to the CF8 WACK books by Ben Forta, and is frequently invited to speak at developer conferences and user groups worldwide.
- Validating Input with Regular Expressions
- Getting Focus()ed and a Quick JavaScript Lesson
- Setting Up Your Development Server with ColdFusion 5, MX, and BlueDragon
- Toward Better Error Handling
- Monitoring Your ColdFusion Environment With the Free Log Parser Toolkit
- New Possibilities for Session/Client Variable Handling in CFMX
- Testing Existence in Arrays
- Making the Case for CFML on J2EE
- Exploring Amazon Web Services with ColdFusion MX
- Getting Focused - and a Quick JavaScript Lesson
- CFML on J2EE: Easy as 1-2-3
- Getting into HomeSite+



























