visionAIR.info

Waiter, there is a bug in my CFC!

Aug 26th 2005
No Comments
respond
trackback

For those of us using ColdFusion as the backend for Flex applications tracking down bugs in a lovingly crafted remote object (CFC) can be a tedious experience.

Firstly, there is a tool at hand that can help; the netConnectionDebugger.swf. Using the default install path for Flex this can be found in the following directory:

C:\Program Files\Macromedia\Flex\extras\netConnectionDebugger

The netConnectionDebugger reports on every remote call of a Flex application and its response from the server. However, if you have some logical bug in your in your CFC remote object it’s not very helpful. For example say, you made a call to a function called ‘loginUser’ (that returns a structure) in Login.cfc and you named a table in a query incorrectly:

[code]
SELECT *
FROM wrongTableName
WHERE User_Name = ‘#User_Name#’
AND Password = ‘#Password#’
[/code]

You will get the rather helpful message in netConnectionDebugger:

“The value returned from function loginUser() is not of type struct.”

Huh? I set the returntype=”struct” in the function! What’s going on?

Of course you could write a unit test page using something like cfunit for every function in every CFC before hooking it to a Flex call; but it is inevitable something will be discovered in user testing you just didn’t see during development and account for in a unit test.

Help is at hand, wrapping all the internal logic of a cffunction with an error trapping custom tag that makes extensive use of cfcatch, you can quickly get to the bottom of many soul destroying bugs.

cf_errorTrapping.zip

cf_errorTrapping will not report on invalid cfml syntax (the parser will do that for you). What it will do is help you track down the really nasty bugs you could otherwise spend hours trying to workout, as it will send a ‘complete’ error report back to the netConnectionDebugger.

Optionally, using request variables cf_errorTrapping can be set to write the error report to a directory and or email it.

Happy debugging!


This post is tagged in ColdFusion, Flex



Explore Recent




No Comments

Leave a Reply