macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Easy <cftry> question

Subject: Easy <cftry> question
From: "NettlesD" <webforumsuser@xxxxxxxxxxxxxx>
Date: Mon, 28 Jul 2008 20:58:29 +0000 (UTC)
Newsgroups: macromedia.coldfusion.cfml_general_discussion

This should be an easy question.

 When writing a <cftry> statement, is it ok to abort within the cfcatch/cftry 
statement or is that a no no for writing code?

 Abort within catch statement:

 <cftry>
   <cfquery name="">
   </cfquery>
   
   <cfcatch type="any">
     <cfinclude template="index.cfm">
      <cfabort>
   </cfcatch>
 </cftry>

 This is the code I have been using but maybe I don't need to do this:

 <cfset foundDatabaseError = "No">

 <cftry>
   <cfquery name="">
   </cfquery>
   
   <cfcatch type="any">
     <cfset foundDatabaseError = "Yes">
   </cfcatch>
 </cftry>

 <cfif foundDatabaseError equal "Yes">
    <cfinclude template="index.cfm">
    <cfabort>
 </cfif>

 My thought was to close the <cftry> statement before jumping to another page 
but maybe that is not necessary.

 Comments?

      


<Prev in Thread] Current Thread [Next in Thread>