Skip to Content
Programming ColdFusion
book

Programming ColdFusion

by Rob Brooks-Bilson
August 2001
Intermediate to advanced
976 pages
38h 8m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion

Custom Exception Handling

In the previous section, we covered the basics of using CFTRY/CFCATCH to handle predefined types of exceptions that might occur within a ColdFusion application. While these general exception types can handle any type of exception, they do so in a generic, one-size-fits-all manner. Fortunately, ColdFusion also allows you to specify custom exception types that can be caught with the same CFTRY/CFCATCH techniques we already covered.

As I mentioned in the previous section, the CFCATCH tag can accept a custom exception type for its TYPE attribute. That custom exception type is defined using the CFTHROW tag. The CFTHROW tag generates a custom exception type that can be caught by a CFCATCH tag when the TYPE attribute is set to Application, Any, or the custom type you specified in the CFTHROW tag. In other words, when something goes wrong in your application, and you need to generate a custom exception, use CFTHROW. The general syntax for using CFTHROW is as follows:

<CFTHROW TYPE="custom_exception_type"
         MESSAGE="error_message"
         DETAIL="detailed_event_description"
         ERRORCODE="error_code"
         EXTENDEDINFO="extended_information">

The CFTHROW tag accepts the following optional attributes:

TYPE

Specifies a name for the exception type. You may give the exception type a custom name or use the predefined type Application.

MESSAGE

Message describing the event that triggered the exception.

DETAIL

Specifies additional information about the exception.

ERRORCODE

A custom ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Programming ColdFusion MX, 2nd Edition

Programming ColdFusion MX, 2nd Edition

Rob Brooks-Bilson

Publisher Resources

ISBN: 1565926986Catalog PageErrata