Name

CFTHROW

Synopsis

<CFTHROW>

Creates a custom exception type that can be caught by the CFTRY/CFCATCH tags when the TYPE attribute of the CFCATCH tag is set to Application, Any, or the custom type you specify in the CFTHROW tag.

As of ColdFusion 4.5.x, you can name custom exception types in a hierarchical manor so that you can reference groups of custom exception types with a single CFCATCH tag. Consider the following CFTHROW tag:

<CFTHROW TYPE="MyApp.RequiredParameters.MyVar">

Any of the three following CFCATCH tags can be used to catch the exception:

<CFCATCH TYPE="MyApp.RequiredParameters.MyVar ">
<CFCATCH TYPE="MyApp.RequiredParameters">
<CFCATCH TYPE="MyApp">

Note that this new behavior in CF 4.5.x results in a potential backward compatibility problem with Version 4.01 of ColdFusion. In Version 4.01, a custom exception coded as:

<CFTHROW TYPE="MyApp.RequiredParameters.MyVar">

can only be caught by an identically named CFCATCH tag, as in:

<CFCATCH TYPE="MyApp.RequiredParameters.MyVar">

but not by these:

<CFCATCH TYPE="MyApp.RequiredParameters">  
<CFCATCH TYPE="MyApp">

This behavior can be manually overridden by including the CFSETTING tag in your Application.cfm template with the CATCHEXCEPTIONSBYPATTERN attribute set to No as in:

<!--- this is the Application.cfm template --->
<CFAPPLICATION NAME="MyApplication">
<CFSETTING CATCHEXCEPTIONSBYPATTERN="No">

Attributes

TYPE=" exception_type "

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

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.