ColdFusion MX added try/catch to the CFSCRIPT, a welcome addition, but you can't throw an exception, or rethrow. Doing a throw is quite easy if you write a UDF for it. However, rethrow is not so easy. You may think:
<cfrethrow>
</cffunction>
However, this will cause a syntax error since rethrow must be contained inside a cfcatch block. For the heck of it, I tried the following:
<cftry>
<cfcatch>
<cfrethrow>
</cfcatch>
</cftry>
</cffunction>
<cftry>
<cfscript>
try {
throw("my type","my ex");
} catch(Exception e) {
rethrow();
}
</cfscript>
<cfcatch>
<cfoutput>exception thrown</cfoutput>
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>
What surprised me is that my rethrow UDF noticed an error had occured and automatically entered the cfcatch block.
This had one problem though. I could call rethrow outside of cfcatch. It wouldn't throw an exception, it would simply do nothing. I modified the UDF like so:
<cftry>
<cfcatch>
<cfrethrow>
</cfcatch>
</cftry>
<cfthrow type="Context validation error" message="Context validation error for CFRETHROW.">
</cffunction>
You will only get to the end of the UDF when you haven't called rethrow() in a catch block.
p.s. Normally I'd add returnType/output/etc to my code. Don't forget to do so if you actually use the UDFs.
p.s.s. And of course, I'd much prefer it if MACR would simply add throw/rethrow to cfscript. :)