For some reason, a piece of code that works fine on a page *.cfmand works fine in *.cfc, now throws an error when an error is detected.
Error:
Element SQL is undefined in CFCATCH.
The code block where this happens is as follows:
<cfcatch type="database">
<cfset errorMessage = "
<p>
<p>Please send the following to a developer:</p>
<p>
<p>
<p>
some other stuff
</cfcatch>
Any thoughts?
UPDATE
Using the @BenKoshy suggestion, I changed the instruction <cfcatch>.
Remember K.I.S.? Keep It Simple Stupid
Using his method and then modifying it, I was getting more data than I used, so I went with a simple version and it works as advertised.
<cfif isDefined("cfcatch.message")>
<cfset errorMessage = errorMessage & "<p>#cfcatch.message#</p>">
</cfif>
<cfif isDefined("cfcatch.SQL")>
<cfset errorMessage = errorMessage & "<p>Please send the following to a developer:</p><p>#cfcatch.SQL#</p>">
</cfif>
<cfif isDefined("cfcatch.QueryError")>
<cfset errorMessage = errorMessage & "<p>#cfcatch.queryError#</p>">
</cfif>
<cfif isDefined("cfcatch.Where")>
<cfset errorMessage = errorMessage & "<p>#cfcatch.Where#</p>">
</cfif>
Nice and light and it works. KISS
Rob m source
share