So, I ran into an interesting issue today. We had some UDFs written in cfscript that used try/catch. The object defined in the cfcatch block was var scoped since... well... we always var scope, right? Consider this code block:
function foo() {
var myerror = "";
x = "apple";
try {
if(x+9) x = 1;
} catch(ANY myerror) {
writeOutput(myerror.message & "<p>");
}
}
</cfscript>
<cfoutput>
#foo()#
</cfoutput>
Everything looks hunkey-dorey, right? However, running this will give you: You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.
Turns out - the var scope of myerror seems to prevent it from being used in the cfcatch block. If you remove the var scope, not only does the code work right, it won't overwrite a variable called myerrors that may exist in the Varibles scope.