Weird Coldfusion Error

So a coworker found this out if you run this test page Coldfusion will return that the cfcatch is not a struct even though when you dump the variable it says that it is a struct. Also on the argument in the function if you put a type="struct" Coldfusion will error out saying that it is not a struct. I have filed a bug here: Bug Also it turns out that it is not just a CF9 issue I have seen it as well in my local CF8 instance.

view plain print about
1<cffunction name="testFunction" output="true">
2    <cfargument name="exception" required="true"/>
3    <cfdump var="#arguments.exception#">
4    <cfdump var="#isStruct(arguments.exception)#">
5</cffunction>
6
7<cftry>
8    <cfthrow message="Help!!!!" />
9    
10    <cfcatch type="any">
11        <cfset testFunction(exception=cfcatch) />
12    </cfcatch>
13</cftry>

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Raymond Camden's Gravatar I believe the issue is that cfcatch is an exception - not a struct. cfdump simply recognizes CF exceptions and displays it as a structure. To me, this is not a bug, or at worse, cfdump being misleading.
# Posted By Raymond Camden | 5/17/10 3:22 PM
Ryan Vikander's Gravatar True it probably isn't an error but it is misleading. The function StructIsEmpty() works with cfcatch but not isStruct(). Also if you duplicate() the cfcatch it reconizes it as a struct. Odd.
# Posted By Ryan Vikander | 5/17/10 3:46 PM
todd sharp's Gravatar For future reference you can always use reflection on variables like so:

<cfdump var="#arguments.exception.getClass().getName()#">

which, in this case returns 'coldfusion.runtime.CustomException'
# Posted By todd sharp | 5/18/10 4:28 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.6.004. Contact Blog Owner