Skip to main content
Known Participant
July 26, 2011
Question

Outputting debug error information in CFcatch

  • July 26, 2011
  • 2 replies
  • 1623 views

Hi there guys -

I'm trying to output pretty much the exact same info that you get in a debug error....with CFcatch.  I cannot, for the life of me, figure out what variables to reference and output to get the same information (after lots of googling and testing different variables).  So far I've been able to determine that cfcatch.message gives you the main error description, but beyond that, I havent been able to figure out what gives you the actual page name, line the error is throwing on, etc etc.

Here's an example of the data I'm trying to replicate via variables and output :

The value '' cannot be converted to a number.

The error occurred in C:\WEBSITES\Milestone OLMS\modules\includes\progressheader.cfm: line 11
Called from C:\WEBSITES\Milestone OLMS\olmsportal.cfm: line 148
Called from C:\WEBSITES\Milestone OLMS\index.cfm: line 4

Any help would be much appreciated!  Thank you!
JE

    This topic has been closed for replies.

    2 replies

    Inspiring
    July 27, 2011

    <cfdump var="#cfcatch#">

    Inspiring
    July 27, 2011

    cfdump var="#cfcatch#"

    Wrap that in a cfsavecontent and you might be on to something.

    Inspiring
    July 27, 2011

    According to the CF9 documentation, what you may be looking for is the cfcatch.tagContext array:

    <cftry>
        <cfset x = "">
        <cfset result = numberFormat(" ", "9999")>
        <cfcatch>
            <cfoutput>
            #cfcatch.message#<br>
            <cfloop from="1" to="#arrayLen(cfcatch.tagContext)#" index="x">
                <cfset tag = cfcatch.tagContext>
                <cfif x gt 1>
                    Called from #tag.template#    line #tag.line#<br>       
                <cfelse>
                    The error occurred in #tag.template#line #tag.line#<br>   
                </cfif>
            </cfloop>
            </cfoutput>
        </cfcatch>
    </cftry>