Coldfusion exception not hitting try / catch list
You can run this cftry gist with the first or second block of code specified, without comment, to see the problem.
<cffunction name="alpha" returntype="boolean">
<cfargument name="boo" type="boolean" />
<cfreturn arguments.boo />
</cffunction>
<cffunction name="beta">
<cfset var temp = {} />
<cftry>
<cfset temp.userID = 1 />
<!--- This way throws an *unhandled* exception --->
<!--- --->
<cfif alpha(structAppend({userID = temp.userID}, foo))>
<cfdump var="It worked" />
</cfif>
<!--- This way works as expected --->
<!---
<cfset temp.args = {userID = temp.userID} />
<cfif alpha(structAppend(temp.args, foo))>
<cfdump var="It worked" />
</cfif>
--->
<cfcatch>
<cfdump var="#cfcatch.message#" />
</cfcatch>
</cftry>
</cffunction>
I know that string literary notation {}
sometimes displays the common names of structs in my debugger, but why should I assign something created with this syntax so that the creation of the structure happens at a different time than if it wasn't assigned?
If I am debugging, I can set a breakpoint on the line where I set temp.userID = 1
it and it jumps right over it. Also, an exception is thrown on the line contained in the try / catch, but fails to catch it.
I know JavaScript has the concept of "hoisting". I can only guess in some (but not all!) Cases where CF does something similar to string literals.
Is this a bug or a known CF behavior?
source to share
No one has answered this question yet
Check out similar questions: