<cftry>

Used with one or more cfcatch tags, the cftry tag lets you catch and process exceptions in CFML pages. Exceptions include events that disrupt the normal flow of instructions in a CFML page, such as failed database operations, missing include files, and developer-specified events.

This tag must have a body.

This tag is also supported within <cfscript>

This tag does not use any attributes.

<cftry><!--- body ---></cftry>

Examples

<cftry>
  <cfquery name="getCountofReminders" datasource="#application.config.DSN#">
    select count(id) from reminders where id = <cfqueryparam value="#arguments.id#" cfsqltype="cf_sql_number">
  </cfquery>
  <cfcatch type="database">
    <cfoutput>
      <p>There was a problem getting a count of your reminders: #cfcatch.queryerror# (for statement: #cfcatch.sql#)</p>
    </cfoutput>
  </cfcatch>
</cftry>

See also