I've got some code here where the author set up a CFTRY block, did a query in it
and then tested the query values. If it failed, he ran a CFTROW and handled the
failure in a CFCATCH (the code is below).
Now can someone, anyone tell me why he didn't just put the two CFSETs from the
CFCATCH into the CFELSE? Is there some best practice to use CFTHROW in this
manner? It seems exceptionally wasteful especially as this will be recorded as
an error in the logs.  He doesn't seem focused on catching an error from the
query, just from the query results. (the code is FULL of instances of this and
is a reason I will never recomend this product to anyone)

 <cftry>
  <cfquery username="#db_username#" password="#db_password#" name="getItem"
datasource="#Attributes.datasource#">
   SELECT COUNT(itemnum) AS found
   FROM items
   WHERE itemnum = #Attributes.itemnum#
  </cfquery>

  <cfif getItem.found>
   <cfset chkItemnum = "TRUE">
  <cfelse>
   <cfthrow>
  </cfif>

  <cfcatch>
   <cfset chkItemnum = "FALSE">
   <cfset whyBadBid = ListAppend(whyBadBid, "Invalid item number.", ",")>
  </cfcatch>
 </cftry>

Michael Dinowitz
Master of the House of Fusion
http://www.houseoffusion.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=5
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=5
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5
                                

Reply via email to