<cfcatch>
Used only inside a <cftry>, the cfcatch tag catches and process exceptions.
By specifying the type of error with the type attribute, different types of exceptions can be handled differently.
This tag must have a body.
This tag is also supported within <cfscript>
<cfcatch
name=string
type=string
><!--- body ---></cfcatch>
Examples
Simple example with cfcatch
<cftry>
<cfset a = 3/0>
<cfdump var="#c#" />
<cfcatch>
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>
Nice trick with echo and cfcatch
try {
throw "demo echo trick";
} catch ( e ){
echo( e ); // outputs the error nicely using the error template
echo( cfcatch ); // lucee always populates cfcatch
}
See also
- Core CFML Language
- Exception Output
- Retry
- <cffinally>
- <cfrethrow>
- <cfretry>
- <cfthrow>
- <cftry>
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)