cftry
Used with one or more cfcatch tags. Together, they catch and process exceptions in CFML pages. Exceptions are events that disrupt the normal flow of instructions in a CFML page, such as failed database operations, missing include files, and developer-specified events.
<cftry>
try { } catch (any e) {}
Examples Sample code using the cftry tag
Create a divide by zero error and then catch it.
try {
x = 5/0;
}
catch (any e) {
writeOutput("Error: " & e.message);
} Expected Result: Error: Division by zero.
Create a divide by zero error and then catch it.
<cftry>
<cfset x = 5/0 />
<cfcatch type="any">
Error: <cfoutput>#cfcatch.message#</cfoutput>
</cfcatch>
</cftry> Expected Result: Error: Division by zero.
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/cftry