tracker issue : CF-3605215

select a category, or use search below
(searches all categories and all time range)
Title:

Error when returning an implicit struct in cfcatch

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

Reporter/Name(from Bugbase): Sanjeev Krishna / Sanjeev Krishna (Sanjeev MANDALAPU)

Created: 07/31/2013

Components: Language

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Windows 7

Vote Count: 0

Duplicate ID:	CF-3605332

Problem Description:

When returning an implicit struct from inside CFCATCH with cfcatch as one of its key value, CF throws an undefined element exception.

<cfscript>
    public STRUCT function blah(){    
        try{
            return {success: true, data: 'ColdFusion'};
        } catch(Any err){
            return {success: false, data: cfcatch.detail};
        }
    }
</cfscript>

The above code throws an "Detail is undefined in CFCATCH" error even without running the code. This is true for the following also -

return {success: false, data: cfcatch}; //throws "CFCATCH is undefined" error

var err = cfcatch;
return {success: false, data: err}; //throws "err is undefined" error

Steps to Reproduce:

<cfscript>
    public STRUCT function blah(){    
        try{
            return {success: true, data: 'ColdFusion'};
        } catch(Any err){
            return {success: false, data: cfcatch.detail};
        }
    }
</cfscript>

Actual Result:

Detail is undefined in CFCATCH

Expected Result:

a struct with success:true and data:ColdFusion

Any Workarounds:

Yes. Use explicit struct declaration

<cfscript>
    public STRUCT function blah(){    
        try{
            return {success: true, data: 'ColdFusion'};
        } catch(Any err){
            var ret = structNew();
                ret.success = false;
                ret.data = cfcatch.detail;
                return ret;        
        }
    }
</cfscript>

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3605215

External Customer Info:
External Company:  
External Customer Name: elixira
External Customer Email:  
External Test Config: My Hardware and Environment details:



ColdFusion 10u10 32bit, Apache as web server and running on a Win7 i5.

Attachments:

Comments:

I can replicate this on CF9 too. Another work-around is to use an intemediary variable: <cffunction name="blahImplicit" returntype="Struct"> <cfset var name = 'ColdFusion'/> <cftry> <cfreturn {success= true, data= name}> <cfcatch type="any"> <cfset var ret = {success= false, data= cfcatch.detail}> <cfreturn ret> </cfcatch> </cftry> </cffunction> -- Adam
Comment by External U.
14759 | August 01, 2013 01:59:57 AM GMT
I could not edit this bug details, so created a duplicate with more detailed reproducible case (Bug CF-3605332) description.
Comment by External U.
14760 | August 01, 2013 02:06:35 AM GMT
Closing this bug as we already have this bug with no. CF-3605332 which is in tofix state (Comment added from ex-user id:nawani)
Comment by Adobe D.
14761 | September 18, 2013 06:37:35 AM GMT