Welcome!

Charlie Arehart

Subscribe to Charlie Arehart: eMailAlertsEmail Alerts
Get Charlie Arehart via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Article

New CFERROR Feature Allows Greater Control

New CFERROR Feature Allows Greater Control

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

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.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.