Twitter: raymondcamden


Address: Lafayette, LA, USA

Quick and dirty debugging tip for Flex/ColdFusion

01-29-2007 6,195 views Flex, ColdFusion

There are multiple methods of debugging applications, including the very cool FusionDebug, log files, ServiceCapture, and the debugging rolled into Flex Builder 2 itself. Here is a quick tip for another method to use. It's ugly - but effective.

Modify your onError to dump the errors and log to a file like so:

view plain print about
1<cffunction name="onError" returnType="void" output="false">
2    <cfargument name="exception" required="true">
3    <cfargument name="eventname" type="string" required="true">
4    <cfset var temp = "">
5
6    <cflog file="my app" text="#arguments.exception.message#, #arguments.exception.detail#">
7    <cfsavecontent variable="temp">
8    <cfdump var="#arguments#">
9    </cfsavecontent>
10    <cffile action="write" file="c:\myapp.html" output="#temp#">
11    <cfdump var="#arguments#"><cfabort>
12</cffunction>

I wrapped a dump of the arguments (which contain my exception) and simply save it to the C drive as an HTML file. I then have this file open in my browser. As I debug, I can simply reload the tab in Firefox to see what the latest error was.

I find this especially useful when the exception message is a bit too vague. With the dump I get the full trace of files where the error occurred.

Let me be absolutely clear: Do not use this code in production. It isn't nice. It doesn't play well with others. It runs with scissors. You get the idea. But I thought I'd share.