I am trying to use a <cftry>
and <cfcatch>
block of code. However I am confused about something, I put a <cftry>
block around my query and the result of that query is not empty, but the condition always goes into the <cfcatch>
block.
Example :
<cftry>
<cfquery name="qcar" datasource="xxxx">
select * from allcar
</cfquery>
<cfcatch>
<script>
alert("ERROR");
</script>
</cfcacth>
</cftry>
What is wrong with this code that it always goes to the <cfcatch>
?
<cfdump var="#cfcatch#" />
will display the full error. This will tell you what caused the error. wikidocs.adobe.com/wiki/display/coldfusionen/cfdump wikidocs.adobe.com/wiki/display/coldfusionen/cfcatchcfcatch
object as beloitdavisja described. You might also want to review the tutorial he posted, because mixing client side (javascript) and server side (CFML) code to handle server errors is not the norm.