Try/catch rethrow in cfscript?

2008-11-21 Thread Gaulin, Mark
Hi
Is there any way to rethrow an exception within a cfscript try/catch
block?

(In case you are wondering, you cannot use cfrethrow in a
cffunction-defined UDF to get around the problem... cfrethrow must be
directly nested inside a cfcatch block.)

-

Ok, I found a work-around (for CF8 only) and figured I might as well
post it:

cffunction name=rethrow output=false access=public
hint=Script version of cfthrow
cfargument name=ex hint=Pass in the already-caught exception
to rethrow

!--- It looks like CF8 added the object option ---
cfthrow object=#arguments.ex#

/cffunction

cfscript
try {
x = 1/0;// exception!
} catch (Any ex) {
rethrow(ex = ex);
}
/cfscript

Thanks
Mark

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315787
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Try/catch rethrow in cfscript?

2008-11-21 Thread Nathan Strutz
Mark,

No, there's no rethrow in cfscript :(
The only real workaround is to use tags for the whole thing :(

nathan strutz
[Blog and Family @ http://www.dopefly.com/]
[AZCFUG Manager @ http://www.azcfug.org/]



On Fri, Nov 21, 2008 at 11:56 AM, Gaulin, Mark [EMAIL PROTECTED]wrote:

 Hi
 Is there any way to rethrow an exception within a cfscript try/catch
 block?

 (In case you are wondering, you cannot use cfrethrow in a
 cffunction-defined UDF to get around the problem... cfrethrow must be
 directly nested inside a cfcatch block.)

 -

 Ok, I found a work-around (for CF8 only) and figured I might as well
 post it:

 cffunction name=rethrow output=false access=public
hint=Script version of cfthrow
cfargument name=ex hint=Pass in the already-caught exception
 to rethrow

!--- It looks like CF8 added the object option ---
cfthrow object=#arguments.ex#

 /cffunction

 cfscript
 try {
x = 1/0;// exception!
 } catch (Any ex) {
rethrow(ex = ex);
 }
 /cfscript

 Thanks
Mark

 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315788
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4