Dumped in Coldfusion

Wednesday, February 15, 2006

No finally in ColdFusion

Coldfusion has gained exceptions at some point, and they have been bolted on quite nicely. Unfortunately they appear to have missed out some parts of the try...catch idiom.

Firstly you cannot do exception handling from <cfscript> tags. This means that if you write a lot of code as cfscript, in order to save on the world supply of angle brackets that would otherwise be absorbed, then you have to keep on switching in and out of cfscript making it even messier.

Update: It appears that you can use try/catch in cfscript. I just found some code that appears to be basically try {} catch (Any exception) {}


Secondly, though there is <cftry> and <cfcatch>, it appears to be missing a <cffinally>.

Surely finally is something that is used quite a bit for tidying up after code. In some cases you can just put the clean-up code outside the try block, but that doesn't work if your code has a <cfabort> or is a user defined function with a return.

This leads to cutting and pasting code between the end of the try-block and the catch-blocks with all of the chances for error that entails.

This just further enforces my thought that Coldfusion is just for VB and PHP programmers that don't have alergic reations to messy code. That said, there are a lot of these "programmers" about, and Coldfusion does a lot of the clearing up for you, reducing the need for finally.

I still think it should be there, for completeness if nothing else.

0 Comments:

Post a Comment

<< Home