Skip to main content
Dileep_NR
Inspiring
August 31, 2010
Question

isstruct with cfcatch

  • August 31, 2010
  • 2 replies
  • 1473 views

I have passed 'cfcatch' to a function and checked the argument with isstruct() and it retrurn 'NO'. Why the isstruct return false

**********************

index.cfm

**********************

<cfoutput>
    <cftry>
        <cfset t.a="Dileep">
        #isstruct(t)#<br />
        #getStruct(t)#<br />
        #getStruct1(t)#<br />
        <cfcatch >
        <br />
        <cfdump var="#cfcatch#">
        #getStruct(cfcatch)#
        </cfcatch>
    </cftry>

</cfoutput>

<cffunction name="getStruct">
    <cfargument name="test">
    <cfreturn isstruct(test)>
</cffunction>

**********************

out put

**********************

YES
YES

struct
Detail[empty string]
ErrNumber0
MessageVariable GETSTRUCT1 is undefined.
StackTracecoldfusion.runtime.UndefinedVariableException: Variable GETSTRUCT1 is undefined.      at coldfusion.runtime.CfJspPage._get(CfJspPage.java:325)      at coldfusion.runtime.CfJspPage._get(CfJspPage.java:287)      at cftest2ecfm1898925283.runPage(D:\Projects\Glasnost\Glasnost\Output\test.cfm:8)      at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196)      at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:483)      at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)      at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:282)      at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)      at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)      at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)      at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)      at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)      at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:74)      at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)      at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)      at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)      at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)      at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)      at coldfusion.CfmServlet.service(CfmServlet.java:198)      at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)      at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)      at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)      at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)      at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)      at jrun.servlet.FilterChain.service(FilterChain.java:101)      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)      at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)      at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)      at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
TagContext
array
1
struct
COLUMN0
ID??
LINE8
RAW_TRACEat cftest2ecfm1898925283.runPage(D:\Projects\Glasnost\Glasnost\Output\test.cfm:8)
TEMPLATED:\Projects\Glasnost\Glasnost\Output\test.cfm
TYPECFML
TypeExpression
nameGETSTRUCT1

NO

    This topic has been closed for replies.

    2 replies

    Inspiring
    December 15, 2010

    CFCATCH is a special case when it comes its type but there's a known workaround. What works best is to call

    <cfset myException = Duplicate(CFCATCH)>

    and then use myException from there on. Calling IsStruct(myException) should now return true.

    Inspiring
    August 31, 2010

    Yep, because the CFCATCH variable is a java.lang.Exception (or extension thereof), not a struct.

    Output this in your <cfcatch> block:

    #cfcatch.getClass().getName()#

    --

    Adam

    Dileep_NR
    Dileep_NRAuthor
    Inspiring
    August 31, 2010

    OK. Thanks.

    But while 'cfdump' shows header as 'struct'. Please see the attched image

    Inspiring
    August 31, 2010

    But while 'cfdump' shows header as 'struct'. Please see the

    attched image

    True, but that is just a label they assigned for the output. While the cfcatch object acts like a regular structure in most ways, technically it is not one.